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.BreedingRecordDetailEntity;

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

    public static final String TABLENAME = "BREEDING_RECORD_DETAIL_ENTITY";

    /**
     * Properties of entity BreedingRecordDetailEntity.<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 FUnid = new Property(1, Long.class, "fUnid", false, "F_UNID");
        public final static Property MatingStyle = new Property(2, String.class, "matingStyle", false, "MATING_STYLE");
        public final static Property CattleresumeId = new Property(3, Long.class, "cattleresumeId", false, "CATTLERESUME_ID");
        public final static Property FrozenSemenBatch = new Property(4, String.class, "frozenSemenBatch", false, "FROZEN_SEMEN_BATCH");
        public final static Property MatingDate = new Property(5, String.class, "matingDate", false, "MATING_DATE");
        public final static Property IsReturn = new Property(6, String.class, "isReturn", false, "IS_RETURN");
        public final static Property BackLoveDate = new Property(7, String.class, "backLoveDate", false, "BACK_LOVE_DATE");
        public final static Property DueDate = new Property(8, String.class, "dueDate", false, "DUE_DATE");
        public final static Property Pregnancy = new Property(9, String.class, "pregnancy", false, "PREGNANCY");
        public final static Property DeptId = new Property(10, Long.class, "deptId", false, "DEPT_ID");
        public final static Property UploadStatus = new Property(11, String.class, "uploadStatus", false, "UPLOAD_STATUS");
        public final static Property SearchValue = new Property(12, String.class, "searchValue", false, "SEARCH_VALUE");
        public final static Property CreateBy = new Property(13, String.class, "createBy", false, "CREATE_BY");
        public final static Property CreateTime = new Property(14, String.class, "createTime", false, "CREATE_TIME");
        public final static Property UpdateBy = new Property(15, String.class, "updateBy", false, "UPDATE_BY");
        public final static Property UpdateTime = new Property(16, String.class, "updateTime", false, "UPDATE_TIME");
        public final static Property Remark = new Property(17, String.class, "remark", false, "REMARK");
    }


    public BreedingRecordDetailEntityDao(DaoConfig config) {
        super(config);
    }
    
    public BreedingRecordDetailEntityDao(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 + "\"BREEDING_RECORD_DETAIL_ENTITY\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: unid
                "\"F_UNID\" INTEGER," + // 1: fUnid
                "\"MATING_STYLE\" TEXT," + // 2: matingStyle
                "\"CATTLERESUME_ID\" INTEGER," + // 3: cattleresumeId
                "\"FROZEN_SEMEN_BATCH\" TEXT," + // 4: frozenSemenBatch
                "\"MATING_DATE\" TEXT," + // 5: matingDate
                "\"IS_RETURN\" TEXT," + // 6: isReturn
                "\"BACK_LOVE_DATE\" TEXT," + // 7: backLoveDate
                "\"DUE_DATE\" TEXT," + // 8: dueDate
                "\"PREGNANCY\" TEXT," + // 9: pregnancy
                "\"DEPT_ID\" INTEGER," + // 10: deptId
                "\"UPLOAD_STATUS\" TEXT," + // 11: uploadStatus
                "\"SEARCH_VALUE\" TEXT," + // 12: searchValue
                "\"CREATE_BY\" TEXT," + // 13: createBy
                "\"CREATE_TIME\" TEXT," + // 14: createTime
                "\"UPDATE_BY\" TEXT," + // 15: updateBy
                "\"UPDATE_TIME\" TEXT," + // 16: updateTime
                "\"REMARK\" TEXT);"); // 17: remark
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, BreedingRecordDetailEntity entity) {
        stmt.clearBindings();
 
        Long unid = entity.getUnid();
        if (unid != null) {
            stmt.bindLong(1, unid);
        }
 
        Long fUnid = entity.getFUnid();
        if (fUnid != null) {
            stmt.bindLong(2, fUnid);
        }
 
        String matingStyle = entity.getMatingStyle();
        if (matingStyle != null) {
            stmt.bindString(3, matingStyle);
        }
 
        Long cattleresumeId = entity.getCattleresumeId();
        if (cattleresumeId != null) {
            stmt.bindLong(4, cattleresumeId);
        }
 
        String frozenSemenBatch = entity.getFrozenSemenBatch();
        if (frozenSemenBatch != null) {
            stmt.bindString(5, frozenSemenBatch);
        }
 
        String matingDate = entity.getMatingDate();
        if (matingDate != null) {
            stmt.bindString(6, matingDate);
        }
 
        String isReturn = entity.getIsReturn();
        if (isReturn != null) {
            stmt.bindString(7, isReturn);
        }
 
        String backLoveDate = entity.getBackLoveDate();
        if (backLoveDate != null) {
            stmt.bindString(8, backLoveDate);
        }
 
        String dueDate = entity.getDueDate();
        if (dueDate != null) {
            stmt.bindString(9, dueDate);
        }
 
        String pregnancy = entity.getPregnancy();
        if (pregnancy != null) {
            stmt.bindString(10, pregnancy);
        }
 
        Long deptId = entity.getDeptId();
        if (deptId != null) {
            stmt.bindLong(11, deptId);
        }
 
        String uploadStatus = entity.getUploadStatus();
        if (uploadStatus != null) {
            stmt.bindString(12, uploadStatus);
        }
 
        String searchValue = entity.getSearchValue();
        if (searchValue != null) {
            stmt.bindString(13, searchValue);
        }
 
        String createBy = entity.getCreateBy();
        if (createBy != null) {
            stmt.bindString(14, createBy);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(15, createTime);
        }
 
        String updateBy = entity.getUpdateBy();
        if (updateBy != null) {
            stmt.bindString(16, updateBy);
        }
 
        String updateTime = entity.getUpdateTime();
        if (updateTime != null) {
            stmt.bindString(17, updateTime);
        }
 
        String remark = entity.getRemark();
        if (remark != null) {
            stmt.bindString(18, remark);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, BreedingRecordDetailEntity entity) {
        stmt.clearBindings();
 
        Long unid = entity.getUnid();
        if (unid != null) {
            stmt.bindLong(1, unid);
        }
 
        Long fUnid = entity.getFUnid();
        if (fUnid != null) {
            stmt.bindLong(2, fUnid);
        }
 
        String matingStyle = entity.getMatingStyle();
        if (matingStyle != null) {
            stmt.bindString(3, matingStyle);
        }
 
        Long cattleresumeId = entity.getCattleresumeId();
        if (cattleresumeId != null) {
            stmt.bindLong(4, cattleresumeId);
        }
 
        String frozenSemenBatch = entity.getFrozenSemenBatch();
        if (frozenSemenBatch != null) {
            stmt.bindString(5, frozenSemenBatch);
        }
 
        String matingDate = entity.getMatingDate();
        if (matingDate != null) {
            stmt.bindString(6, matingDate);
        }
 
        String isReturn = entity.getIsReturn();
        if (isReturn != null) {
            stmt.bindString(7, isReturn);
        }
 
        String backLoveDate = entity.getBackLoveDate();
        if (backLoveDate != null) {
            stmt.bindString(8, backLoveDate);
        }
 
        String dueDate = entity.getDueDate();
        if (dueDate != null) {
            stmt.bindString(9, dueDate);
        }
 
        String pregnancy = entity.getPregnancy();
        if (pregnancy != null) {
            stmt.bindString(10, pregnancy);
        }
 
        Long deptId = entity.getDeptId();
        if (deptId != null) {
            stmt.bindLong(11, deptId);
        }
 
        String uploadStatus = entity.getUploadStatus();
        if (uploadStatus != null) {
            stmt.bindString(12, uploadStatus);
        }
 
        String searchValue = entity.getSearchValue();
        if (searchValue != null) {
            stmt.bindString(13, searchValue);
        }
 
        String createBy = entity.getCreateBy();
        if (createBy != null) {
            stmt.bindString(14, createBy);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(15, createTime);
        }
 
        String updateBy = entity.getUpdateBy();
        if (updateBy != null) {
            stmt.bindString(16, updateBy);
        }
 
        String updateTime = entity.getUpdateTime();
        if (updateTime != null) {
            stmt.bindString(17, updateTime);
        }
 
        String remark = entity.getRemark();
        if (remark != null) {
            stmt.bindString(18, remark);
        }
    }

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

    @Override
    public BreedingRecordDetailEntity readEntity(Cursor cursor, int offset) {
        BreedingRecordDetailEntity entity = new BreedingRecordDetailEntity( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // unid
            cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // fUnid
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // matingStyle
            cursor.isNull(offset + 3) ? null : cursor.getLong(offset + 3), // cattleresumeId
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // frozenSemenBatch
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // matingDate
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isReturn
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // backLoveDate
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // dueDate
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // pregnancy
            cursor.isNull(offset + 10) ? null : cursor.getLong(offset + 10), // deptId
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // uploadStatus
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // searchValue
            cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // createBy
            cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // createTime
            cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // updateBy
            cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // updateTime
            cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17) // remark
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, BreedingRecordDetailEntity entity, int offset) {
        entity.setUnid(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setFUnid(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
        entity.setMatingStyle(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setCattleresumeId(cursor.isNull(offset + 3) ? null : cursor.getLong(offset + 3));
        entity.setFrozenSemenBatch(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setMatingDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setIsReturn(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setBackLoveDate(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setDueDate(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setPregnancy(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setDeptId(cursor.isNull(offset + 10) ? null : cursor.getLong(offset + 10));
        entity.setUploadStatus(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setSearchValue(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
        entity.setCreateBy(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
        entity.setCreateTime(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
        entity.setUpdateBy(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
        entity.setUpdateTime(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16));
        entity.setRemark(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(BreedingRecordDetailEntity entity, long rowId) {
        entity.setUnid(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(BreedingRecordDetailEntity entity) {
        if(entity != null) {
            return entity.getUnid();
        } else {
            return null;
        }
    }

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

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