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

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

    public static final String TABLENAME = "BREEDING_RECORD_ENTITY";

    /**
     * Properties of entity BreedingRecordEntity.<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 CattleresumeId = new Property(1, Long.class, "cattleresumeId", false, "CATTLERESUME_ID");
        public final static Property RaiseVarieties = new Property(2, String.class, "raiseVarieties", false, "RAISE_VARIETIES");
        public final static Property Location = new Property(3, String.class, "location", false, "LOCATION");
        public final static Property BreedingPlantId = new Property(4, String.class, "breedingPlantId", false, "BREEDING_PLANT_ID");
        public final static Property UploadStatus = new Property(5, String.class, "uploadStatus", false, "UPLOAD_STATUS");
        public final static Property DeptId = new Property(6, Long.class, "deptId", false, "DEPT_ID");
        public final static Property SearchValue = new Property(7, String.class, "searchValue", false, "SEARCH_VALUE");
        public final static Property CreateBy = new Property(8, String.class, "createBy", false, "CREATE_BY");
        public final static Property CreateTime = new Property(9, String.class, "createTime", false, "CREATE_TIME");
        public final static Property UpdateBy = new Property(10, String.class, "updateBy", false, "UPDATE_BY");
        public final static Property UpdateTime = new Property(11, String.class, "updateTime", false, "UPDATE_TIME");
        public final static Property Remark = new Property(12, String.class, "remark", false, "REMARK");
    }


    public BreedingRecordEntityDao(DaoConfig config) {
        super(config);
    }
    
    public BreedingRecordEntityDao(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_ENTITY\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: unid
                "\"CATTLERESUME_ID\" INTEGER," + // 1: cattleresumeId
                "\"RAISE_VARIETIES\" TEXT," + // 2: raiseVarieties
                "\"LOCATION\" TEXT," + // 3: location
                "\"BREEDING_PLANT_ID\" TEXT," + // 4: breedingPlantId
                "\"UPLOAD_STATUS\" TEXT," + // 5: uploadStatus
                "\"DEPT_ID\" INTEGER," + // 6: deptId
                "\"SEARCH_VALUE\" TEXT," + // 7: searchValue
                "\"CREATE_BY\" TEXT," + // 8: createBy
                "\"CREATE_TIME\" TEXT," + // 9: createTime
                "\"UPDATE_BY\" TEXT," + // 10: updateBy
                "\"UPDATE_TIME\" TEXT," + // 11: updateTime
                "\"REMARK\" TEXT);"); // 12: remark
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, BreedingRecordEntity entity) {
        stmt.clearBindings();
 
        Long unid = entity.getUnid();
        if (unid != null) {
            stmt.bindLong(1, unid);
        }
 
        Long cattleresumeId = entity.getCattleresumeId();
        if (cattleresumeId != null) {
            stmt.bindLong(2, cattleresumeId);
        }
 
        String raiseVarieties = entity.getRaiseVarieties();
        if (raiseVarieties != null) {
            stmt.bindString(3, raiseVarieties);
        }
 
        String location = entity.getLocation();
        if (location != null) {
            stmt.bindString(4, location);
        }
 
        String breedingPlantId = entity.getBreedingPlantId();
        if (breedingPlantId != null) {
            stmt.bindString(5, breedingPlantId);
        }
 
        String uploadStatus = entity.getUploadStatus();
        if (uploadStatus != null) {
            stmt.bindString(6, uploadStatus);
        }
 
        Long deptId = entity.getDeptId();
        if (deptId != null) {
            stmt.bindLong(7, deptId);
        }
 
        String searchValue = entity.getSearchValue();
        if (searchValue != null) {
            stmt.bindString(8, searchValue);
        }
 
        String createBy = entity.getCreateBy();
        if (createBy != null) {
            stmt.bindString(9, createBy);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(10, createTime);
        }
 
        String updateBy = entity.getUpdateBy();
        if (updateBy != null) {
            stmt.bindString(11, updateBy);
        }
 
        String updateTime = entity.getUpdateTime();
        if (updateTime != null) {
            stmt.bindString(12, updateTime);
        }
 
        String remark = entity.getRemark();
        if (remark != null) {
            stmt.bindString(13, remark);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, BreedingRecordEntity entity) {
        stmt.clearBindings();
 
        Long unid = entity.getUnid();
        if (unid != null) {
            stmt.bindLong(1, unid);
        }
 
        Long cattleresumeId = entity.getCattleresumeId();
        if (cattleresumeId != null) {
            stmt.bindLong(2, cattleresumeId);
        }
 
        String raiseVarieties = entity.getRaiseVarieties();
        if (raiseVarieties != null) {
            stmt.bindString(3, raiseVarieties);
        }
 
        String location = entity.getLocation();
        if (location != null) {
            stmt.bindString(4, location);
        }
 
        String breedingPlantId = entity.getBreedingPlantId();
        if (breedingPlantId != null) {
            stmt.bindString(5, breedingPlantId);
        }
 
        String uploadStatus = entity.getUploadStatus();
        if (uploadStatus != null) {
            stmt.bindString(6, uploadStatus);
        }
 
        Long deptId = entity.getDeptId();
        if (deptId != null) {
            stmt.bindLong(7, deptId);
        }
 
        String searchValue = entity.getSearchValue();
        if (searchValue != null) {
            stmt.bindString(8, searchValue);
        }
 
        String createBy = entity.getCreateBy();
        if (createBy != null) {
            stmt.bindString(9, createBy);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(10, createTime);
        }
 
        String updateBy = entity.getUpdateBy();
        if (updateBy != null) {
            stmt.bindString(11, updateBy);
        }
 
        String updateTime = entity.getUpdateTime();
        if (updateTime != null) {
            stmt.bindString(12, updateTime);
        }
 
        String remark = entity.getRemark();
        if (remark != null) {
            stmt.bindString(13, remark);
        }
    }

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

    @Override
    public BreedingRecordEntity readEntity(Cursor cursor, int offset) {
        BreedingRecordEntity entity = new BreedingRecordEntity( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // unid
            cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // cattleresumeId
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // raiseVarieties
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // location
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // breedingPlantId
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // uploadStatus
            cursor.isNull(offset + 6) ? null : cursor.getLong(offset + 6), // deptId
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // searchValue
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // createBy
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // createTime
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // updateBy
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // updateTime
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12) // remark
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, BreedingRecordEntity entity, int offset) {
        entity.setUnid(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setCattleresumeId(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
        entity.setRaiseVarieties(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setLocation(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setBreedingPlantId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setUploadStatus(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setDeptId(cursor.isNull(offset + 6) ? null : cursor.getLong(offset + 6));
        entity.setSearchValue(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setCreateBy(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setCreateTime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setUpdateBy(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setUpdateTime(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setRemark(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(BreedingRecordEntity entity, long rowId) {
        entity.setUnid(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(BreedingRecordEntity entity) {
        if(entity != null) {
            return entity.getUnid();
        } else {
            return null;
        }
    }

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

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