package com.jingpu.android.apersistance.greendao.model;

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

import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;

import com.jingpu.android.apersistance.greendao.model.Stock;

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

    public static final String TABLENAME = "STOCK";

    /**
     * Properties of entity Stock.<br/>
     * Can be used for QueryBuilder and for referencing column names.
    */
    public static class Properties {
        public final static Property SCompo = new Property(0, String.class, "sCompo", true, "S_COMPO");
        public final static Property SIId = new Property(1, int.class, "sIId", false, "S_I_ID");
        public final static Property SWId = new Property(2, short.class, "sWId", false, "S_W_ID");
        public final static Property SQuantity = new Property(3, int.class, "sQuantity", false, "S_QUANTITY");
        public final static Property SDist01 = new Property(4, String.class, "sDist01", false, "S_DIST01");
        public final static Property SDist02 = new Property(5, String.class, "sDist02", false, "S_DIST02");
        public final static Property SDist03 = new Property(6, String.class, "sDist03", false, "S_DIST03");
        public final static Property SDist04 = new Property(7, String.class, "sDist04", false, "S_DIST04");
        public final static Property SDist05 = new Property(8, String.class, "sDist05", false, "S_DIST05");
        public final static Property SDist06 = new Property(9, String.class, "sDist06", false, "S_DIST06");
        public final static Property SDist07 = new Property(10, String.class, "sDist07", false, "S_DIST07");
        public final static Property SDist08 = new Property(11, String.class, "sDist08", false, "S_DIST08");
        public final static Property SDist09 = new Property(12, String.class, "sDist09", false, "S_DIST09");
        public final static Property SDist10 = new Property(13, String.class, "sDist10", false, "S_DIST10");
        public final static Property SYtd = new Property(14, float.class, "sYtd", false, "S_YTD");
        public final static Property SOrderCnt = new Property(15, int.class, "sOrderCnt", false, "S_ORDER_CNT");
        public final static Property SRemoteCnt = new Property(16, int.class, "sRemoteCnt", false, "S_REMOTE_CNT");
        public final static Property SData = new Property(17, String.class, "sData", false, "S_DATA");
        public final static Property SQuantityInitial = new Property(18, int.class, "sQuantityInitial", false, "S_QUANTITY_INITIAL");
    };


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

    /** Creates the underlying database table. */
    public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"STOCK\" (" + //
                "\"S_COMPO\" TEXT PRIMARY KEY NOT NULL ," + // 0: sCompo
                "\"S_I_ID\" INTEGER NOT NULL ," + // 1: sIId
                "\"S_W_ID\" INTEGER NOT NULL ," + // 2: sWId
                "\"S_QUANTITY\" INTEGER NOT NULL ," + // 3: sQuantity
                "\"S_DIST01\" TEXT NOT NULL ," + // 4: sDist01
                "\"S_DIST02\" TEXT NOT NULL ," + // 5: sDist02
                "\"S_DIST03\" TEXT NOT NULL ," + // 6: sDist03
                "\"S_DIST04\" TEXT NOT NULL ," + // 7: sDist04
                "\"S_DIST05\" TEXT NOT NULL ," + // 8: sDist05
                "\"S_DIST06\" TEXT NOT NULL ," + // 9: sDist06
                "\"S_DIST07\" TEXT NOT NULL ," + // 10: sDist07
                "\"S_DIST08\" TEXT NOT NULL ," + // 11: sDist08
                "\"S_DIST09\" TEXT NOT NULL ," + // 12: sDist09
                "\"S_DIST10\" TEXT NOT NULL ," + // 13: sDist10
                "\"S_YTD\" REAL NOT NULL ," + // 14: sYtd
                "\"S_ORDER_CNT\" INTEGER NOT NULL ," + // 15: sOrderCnt
                "\"S_REMOTE_CNT\" INTEGER NOT NULL ," + // 16: sRemoteCnt
                "\"S_DATA\" TEXT NOT NULL ," + // 17: sData
                "\"S_QUANTITY_INITIAL\" INTEGER NOT NULL );"); // 18: sQuantityInitial
    }

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

    /** @inheritdoc */
    @Override
    protected void bindValues(SQLiteStatement stmt, Stock entity) {
        stmt.clearBindings();
 
        String sCompo = entity.getSCompo();
        if (sCompo != null) {
            stmt.bindString(1, sCompo);
        }
        stmt.bindLong(2, entity.getSIId());
        stmt.bindLong(3, entity.getSWId());
        stmt.bindLong(4, entity.getSQuantity());
        stmt.bindString(5, entity.getSDist01());
        stmt.bindString(6, entity.getSDist02());
        stmt.bindString(7, entity.getSDist03());
        stmt.bindString(8, entity.getSDist04());
        stmt.bindString(9, entity.getSDist05());
        stmt.bindString(10, entity.getSDist06());
        stmt.bindString(11, entity.getSDist07());
        stmt.bindString(12, entity.getSDist08());
        stmt.bindString(13, entity.getSDist09());
        stmt.bindString(14, entity.getSDist10());
        stmt.bindDouble(15, entity.getSYtd());
        stmt.bindLong(16, entity.getSOrderCnt());
        stmt.bindLong(17, entity.getSRemoteCnt());
        stmt.bindString(18, entity.getSData());
        stmt.bindLong(19, entity.getSQuantityInitial());
    }

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

    /** @inheritdoc */
    @Override
    public Stock readEntity(Cursor cursor, int offset) {
        Stock entity = new Stock( //
            cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // sCompo
            cursor.getInt(offset + 1), // sIId
            cursor.getShort(offset + 2), // sWId
            cursor.getInt(offset + 3), // sQuantity
            cursor.getString(offset + 4), // sDist01
            cursor.getString(offset + 5), // sDist02
            cursor.getString(offset + 6), // sDist03
            cursor.getString(offset + 7), // sDist04
            cursor.getString(offset + 8), // sDist05
            cursor.getString(offset + 9), // sDist06
            cursor.getString(offset + 10), // sDist07
            cursor.getString(offset + 11), // sDist08
            cursor.getString(offset + 12), // sDist09
            cursor.getString(offset + 13), // sDist10
            cursor.getFloat(offset + 14), // sYtd
            cursor.getInt(offset + 15), // sOrderCnt
            cursor.getInt(offset + 16), // sRemoteCnt
            cursor.getString(offset + 17), // sData
            cursor.getInt(offset + 18) // sQuantityInitial
        );
        return entity;
    }
     
    /** @inheritdoc */
    @Override
    public void readEntity(Cursor cursor, Stock entity, int offset) {
        entity.setSCompo(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
        entity.setSIId(cursor.getInt(offset + 1));
        entity.setSWId(cursor.getShort(offset + 2));
        entity.setSQuantity(cursor.getInt(offset + 3));
        entity.setSDist01(cursor.getString(offset + 4));
        entity.setSDist02(cursor.getString(offset + 5));
        entity.setSDist03(cursor.getString(offset + 6));
        entity.setSDist04(cursor.getString(offset + 7));
        entity.setSDist05(cursor.getString(offset + 8));
        entity.setSDist06(cursor.getString(offset + 9));
        entity.setSDist07(cursor.getString(offset + 10));
        entity.setSDist08(cursor.getString(offset + 11));
        entity.setSDist09(cursor.getString(offset + 12));
        entity.setSDist10(cursor.getString(offset + 13));
        entity.setSYtd(cursor.getFloat(offset + 14));
        entity.setSOrderCnt(cursor.getInt(offset + 15));
        entity.setSRemoteCnt(cursor.getInt(offset + 16));
        entity.setSData(cursor.getString(offset + 17));
        entity.setSQuantityInitial(cursor.getInt(offset + 18));
     }
    
    /** @inheritdoc */
    @Override
    protected String updateKeyAfterInsert(Stock entity, long rowId) {
        return entity.getSCompo();
    }
    
    /** @inheritdoc */
    @Override
    public String getKey(Stock entity) {
        if(entity != null) {
            return entity.getSCompo();
        } else {
            return null;
        }
    }

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