package com.adins.mss.dao;

import android.database.Cursor;

import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;
import de.greenrobot.dao.database.Database;
import de.greenrobot.dao.database.DatabaseStatement;

import com.adins.mss.dao.LastSync;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "TR_LASTSYNC".
*/
public class LastSyncDao extends AbstractDao<LastSync, String> {

    public static final String TABLENAME = "TR_LASTSYNC";

    /**
     * Properties of entity LastSync.<br/>
     * Can be used for QueryBuilder and for referencing column names.
    */
    public static class Properties {
        public final static Property Uuid_last_sync = new Property(0, String.class, "uuid_last_sync", true, "UUID_LAST_SYNC");
        public final static Property Dtm_lastsync = new Property(1, java.util.Date.class, "dtm_lastsync", false, "DTM_LASTSYNC");
        public final static Property Dtm_req = new Property(2, String.class, "dtm_req", false, "DTM_REQ");
        public final static Property Data = new Property(3, String.class, "data", false, "DATA");
        public final static Property ListOfLOV = new Property(4, String.class, "listOfLOV", false, "LIST_OF_LOV");
        public final static Property Flag = new Property(5, String.class, "flag", false, "FLAG");
        public final static Property Is_send = new Property(6, Integer.class, "is_send", false, "IS_SEND");
    };


    public LastSyncDao(DaoConfig config) {
        super(config);
    }
    
    public LastSyncDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"TR_LASTSYNC\" (" + //
                "\"UUID_LAST_SYNC\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid_last_sync
                "\"DTM_LASTSYNC\" INTEGER," + // 1: dtm_lastsync
                "\"DTM_REQ\" TEXT," + // 2: dtm_req
                "\"DATA\" TEXT," + // 3: data
                "\"LIST_OF_LOV\" TEXT," + // 4: listOfLOV
                "\"FLAG\" TEXT," + // 5: flag
                "\"IS_SEND\" INTEGER);"); // 6: is_send
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TR_LASTSYNC\"";
        db.execSQL(sql);
    }

    /** @inheritdoc */
    @Override
    protected void bindValues(DatabaseStatement stmt, LastSync entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getUuid_last_sync());
 
        java.util.Date dtm_lastsync = entity.getDtm_lastsync();
        if (dtm_lastsync != null) {
            stmt.bindLong(2, dtm_lastsync.getTime());
        }
 
        String dtm_req = entity.getDtm_req();
        if (dtm_req != null) {
            stmt.bindString(3, dtm_req);
        }
 
        String data = entity.getData();
        if (data != null) {
            stmt.bindString(4, data);
        }
 
        String listOfLOV = entity.getListOfLOV();
        if (listOfLOV != null) {
            stmt.bindString(5, listOfLOV);
        }
 
        String flag = entity.getFlag();
        if (flag != null) {
            stmt.bindString(6, flag);
        }
 
        Integer is_send = entity.getIs_send();
        if (is_send != null) {
            stmt.bindLong(7, is_send);
        }
    }

    /** @inheritdoc */
    @Override
    public String readKey(Cursor cursor, int offset) {
        return cursor.getString(offset + 0);
    }    

    /** @inheritdoc */
    @Override
    public LastSync readEntity(Cursor cursor, int offset) {
        LastSync entity = new LastSync( //
            cursor.getString(offset + 0), // uuid_last_sync
            cursor.isNull(offset + 1) ? null : new java.util.Date(cursor.getLong(offset + 1)), // dtm_lastsync
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // dtm_req
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // data
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // listOfLOV
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // flag
            cursor.isNull(offset + 6) ? null : cursor.getInt(offset + 6) // is_send
        );
        return entity;
    }
     
    /** @inheritdoc */
    @Override
    public void readEntity(Cursor cursor, LastSync entity, int offset) {
        entity.setUuid_last_sync(cursor.getString(offset + 0));
        entity.setDtm_lastsync(cursor.isNull(offset + 1) ? null : new java.util.Date(cursor.getLong(offset + 1)));
        entity.setDtm_req(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setData(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setListOfLOV(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setFlag(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setIs_send(cursor.isNull(offset + 6) ? null : cursor.getInt(offset + 6));
     }
    
    /** @inheritdoc */
    @Override
    protected String updateKeyAfterInsert(LastSync entity, long rowId) {
        return entity.getUuid_last_sync();
    }
    
    /** @inheritdoc */
    @Override
    public String getKey(LastSync entity) {
        if(entity != null) {
            return entity.getUuid_last_sync();
        } else {
            return null;
        }
    }

    /** @inheritdoc */
    @Override    
    protected boolean isEntityUpdateable() {
        return true;
    }
    
}
