package com.phlx.anchorcollect_p.db.gen;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import com.phlx.anchorcollect_p.entity.ImmuneBatchDetailEntity;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "IMMUNE_BATCH_DETAIL_ENTITY".
*/
public class ImmuneBatchDetailEntityDao extends AbstractDao<ImmuneBatchDetailEntity, Long> {

    public static final String TABLENAME = "IMMUNE_BATCH_DETAIL_ENTITY";

    /**
     * Properties of entity ImmuneBatchDetailEntity.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Unid = new Property(0, Long.class, "unid", true, "_id");
        public final static Property CattleresumeUnid = new Property(1, Long.class, "cattleresumeUnid", false, "CATTLERESUME_UNID");
        public final static Property ImmunebatchUnid = new Property(2, Long.class, "immunebatchUnid", false, "IMMUNEBATCH_UNID");
        public final static Property DeptId = new Property(3, Long.class, "deptId", false, "DEPT_ID");
        public final static Property UploadStatus = new Property(4, String.class, "uploadStatus", false, "UPLOAD_STATUS");
    }


    public ImmuneBatchDetailEntityDao(DaoConfig config) {
        super(config);
    }
    
    public ImmuneBatchDetailEntityDao(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 + "\"IMMUNE_BATCH_DETAIL_ENTITY\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: unid
                "\"CATTLERESUME_UNID\" INTEGER," + // 1: cattleresumeUnid
                "\"IMMUNEBATCH_UNID\" INTEGER," + // 2: immunebatchUnid
                "\"DEPT_ID\" INTEGER," + // 3: deptId
                "\"UPLOAD_STATUS\" TEXT);"); // 4: uploadStatus
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, ImmuneBatchDetailEntity entity) {
        stmt.clearBindings();
 
        Long unid = entity.getUnid();
        if (unid != null) {
            stmt.bindLong(1, unid);
        }
 
        Long cattleresumeUnid = entity.getCattleresumeUnid();
        if (cattleresumeUnid != null) {
            stmt.bindLong(2, cattleresumeUnid);
        }
 
        Long immunebatchUnid = entity.getImmunebatchUnid();
        if (immunebatchUnid != null) {
            stmt.bindLong(3, immunebatchUnid);
        }
 
        Long deptId = entity.getDeptId();
        if (deptId != null) {
            stmt.bindLong(4, deptId);
        }
 
        String uploadStatus = entity.getUploadStatus();
        if (uploadStatus != null) {
            stmt.bindString(5, uploadStatus);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, ImmuneBatchDetailEntity entity) {
        stmt.clearBindings();
 
        Long unid = entity.getUnid();
        if (unid != null) {
            stmt.bindLong(1, unid);
        }
 
        Long cattleresumeUnid = entity.getCattleresumeUnid();
        if (cattleresumeUnid != null) {
            stmt.bindLong(2, cattleresumeUnid);
        }
 
        Long immunebatchUnid = entity.getImmunebatchUnid();
        if (immunebatchUnid != null) {
            stmt.bindLong(3, immunebatchUnid);
        }
 
        Long deptId = entity.getDeptId();
        if (deptId != null) {
            stmt.bindLong(4, deptId);
        }
 
        String uploadStatus = entity.getUploadStatus();
        if (uploadStatus != null) {
            stmt.bindString(5, uploadStatus);
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public ImmuneBatchDetailEntity readEntity(Cursor cursor, int offset) {
        ImmuneBatchDetailEntity entity = new ImmuneBatchDetailEntity( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // unid
            cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // cattleresumeUnid
            cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2), // immunebatchUnid
            cursor.isNull(offset + 3) ? null : cursor.getLong(offset + 3), // deptId
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4) // uploadStatus
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, ImmuneBatchDetailEntity entity, int offset) {
        entity.setUnid(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setCattleresumeUnid(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
        entity.setImmunebatchUnid(cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2));
        entity.setDeptId(cursor.isNull(offset + 3) ? null : cursor.getLong(offset + 3));
        entity.setUploadStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(ImmuneBatchDetailEntity entity, long rowId) {
        entity.setUnid(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(ImmuneBatchDetailEntity entity) {
        if(entity != null) {
            return entity.getUnid();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(ImmuneBatchDetailEntity entity) {
        return entity.getUnid() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}
