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

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

    public static final String TABLENAME = "MEDICAL_RECORD_ENTITY";

    /**
     * Properties of entity MedicalRecordEntity.<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 TreatDate = new Property(2, String.class, "treatDate", false, "TREAT_DATE");
        public final static Property TreatPersonnel = new Property(3, String.class, "treatPersonnel", false, "TREAT_PERSONNEL");
        public final static Property CauseOf = new Property(4, String.class, "causeOf", false, "CAUSE_OF");
        public final static Property DrugName = new Property(5, String.class, "drugName", false, "DRUG_NAME");
        public final static Property Specifications = new Property(6, String.class, "specifications", false, "SPECIFICATIONS");
        public final static Property DrugMethods = new Property(7, String.class, "drugMethods", false, "DRUG_METHODS");
        public final static Property DrugNumber = new Property(8, Double.class, "drugNumber", false, "DRUG_NUMBER");
        public final static Property Results = new Property(9, String.class, "results", false, "RESULTS");
        public final static Property UploadStatus = new Property(10, String.class, "uploadStatus", false, "UPLOAD_STATUS");
        public final static Property DeptId = new Property(11, Long.class, "deptId", false, "DEPT_ID");
        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 MedicalRecordEntityDao(DaoConfig config) {
        super(config);
    }
    
    public MedicalRecordEntityDao(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 + "\"MEDICAL_RECORD_ENTITY\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: unid
                "\"CATTLERESUME_ID\" INTEGER," + // 1: cattleresumeId
                "\"TREAT_DATE\" TEXT," + // 2: treatDate
                "\"TREAT_PERSONNEL\" TEXT," + // 3: treatPersonnel
                "\"CAUSE_OF\" TEXT," + // 4: causeOf
                "\"DRUG_NAME\" TEXT," + // 5: drugName
                "\"SPECIFICATIONS\" TEXT," + // 6: specifications
                "\"DRUG_METHODS\" TEXT," + // 7: drugMethods
                "\"DRUG_NUMBER\" REAL," + // 8: drugNumber
                "\"RESULTS\" TEXT," + // 9: results
                "\"UPLOAD_STATUS\" TEXT," + // 10: uploadStatus
                "\"DEPT_ID\" INTEGER," + // 11: deptId
                "\"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 " : "") + "\"MEDICAL_RECORD_ENTITY\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, MedicalRecordEntity 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 treatDate = entity.getTreatDate();
        if (treatDate != null) {
            stmt.bindString(3, treatDate);
        }
 
        String treatPersonnel = entity.getTreatPersonnel();
        if (treatPersonnel != null) {
            stmt.bindString(4, treatPersonnel);
        }
 
        String causeOf = entity.getCauseOf();
        if (causeOf != null) {
            stmt.bindString(5, causeOf);
        }
 
        String drugName = entity.getDrugName();
        if (drugName != null) {
            stmt.bindString(6, drugName);
        }
 
        String specifications = entity.getSpecifications();
        if (specifications != null) {
            stmt.bindString(7, specifications);
        }
 
        String drugMethods = entity.getDrugMethods();
        if (drugMethods != null) {
            stmt.bindString(8, drugMethods);
        }
 
        Double drugNumber = entity.getDrugNumber();
        if (drugNumber != null) {
            stmt.bindDouble(9, drugNumber);
        }
 
        String results = entity.getResults();
        if (results != null) {
            stmt.bindString(10, results);
        }
 
        String uploadStatus = entity.getUploadStatus();
        if (uploadStatus != null) {
            stmt.bindString(11, uploadStatus);
        }
 
        Long deptId = entity.getDeptId();
        if (deptId != null) {
            stmt.bindLong(12, deptId);
        }
 
        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, MedicalRecordEntity 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 treatDate = entity.getTreatDate();
        if (treatDate != null) {
            stmt.bindString(3, treatDate);
        }
 
        String treatPersonnel = entity.getTreatPersonnel();
        if (treatPersonnel != null) {
            stmt.bindString(4, treatPersonnel);
        }
 
        String causeOf = entity.getCauseOf();
        if (causeOf != null) {
            stmt.bindString(5, causeOf);
        }
 
        String drugName = entity.getDrugName();
        if (drugName != null) {
            stmt.bindString(6, drugName);
        }
 
        String specifications = entity.getSpecifications();
        if (specifications != null) {
            stmt.bindString(7, specifications);
        }
 
        String drugMethods = entity.getDrugMethods();
        if (drugMethods != null) {
            stmt.bindString(8, drugMethods);
        }
 
        Double drugNumber = entity.getDrugNumber();
        if (drugNumber != null) {
            stmt.bindDouble(9, drugNumber);
        }
 
        String results = entity.getResults();
        if (results != null) {
            stmt.bindString(10, results);
        }
 
        String uploadStatus = entity.getUploadStatus();
        if (uploadStatus != null) {
            stmt.bindString(11, uploadStatus);
        }
 
        Long deptId = entity.getDeptId();
        if (deptId != null) {
            stmt.bindLong(12, deptId);
        }
 
        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 MedicalRecordEntity readEntity(Cursor cursor, int offset) {
        MedicalRecordEntity entity = new MedicalRecordEntity( //
            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), // treatDate
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // treatPersonnel
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // causeOf
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // drugName
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // specifications
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // drugMethods
            cursor.isNull(offset + 8) ? null : cursor.getDouble(offset + 8), // drugNumber
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // results
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // uploadStatus
            cursor.isNull(offset + 11) ? null : cursor.getLong(offset + 11), // deptId
            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, MedicalRecordEntity 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.setTreatDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setTreatPersonnel(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setCauseOf(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setDrugName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setSpecifications(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setDrugMethods(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setDrugNumber(cursor.isNull(offset + 8) ? null : cursor.getDouble(offset + 8));
        entity.setResults(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setUploadStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setDeptId(cursor.isNull(offset + 11) ? null : cursor.getLong(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(MedicalRecordEntity entity, long rowId) {
        entity.setUnid(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(MedicalRecordEntity entity) {
        if(entity != null) {
            return entity.getUnid();
        } else {
            return null;
        }
    }

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

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