ContainerInfoDao.java 5.89 KB
package com.huaheng.wms.wmsgreendao;

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.huaheng.wms.work.onshell.ContainerInfo;

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

    public static final String TABLENAME = "CONTAINER_INFO";

    /**
     * Properties of entity ContainerInfo.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property _id = new Property(0, long.class, "_id", true, "_id");
        public final static Property Qty = new Property(1, float.class, "qty", false, "QTY");
        public final static Property Name = new Property(2, String.class, "name", false, "NAME");
        public final static Property Id = new Property(3, int.class, "id", false, "ID");
        public final static Property LocationCode = new Property(4, String.class, "locationCode", false, "LOCATION_CODE");
        public final static Property ReceiptId = new Property(5, int.class, "receiptId", false, "RECEIPT_ID");
        public final static Property Barcode = new Property(6, String.class, "barcode", false, "BARCODE");
    }


    public ContainerInfoDao(DaoConfig config) {
        super(config);
    }
    
    public ContainerInfoDao(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 + "\"CONTAINER_INFO\" (" + //
                "\"_id\" INTEGER PRIMARY KEY NOT NULL ," + // 0: _id
                "\"QTY\" REAL NOT NULL ," + // 1: qty
                "\"NAME\" TEXT," + // 2: name
                "\"ID\" INTEGER NOT NULL ," + // 3: id
                "\"LOCATION_CODE\" TEXT," + // 4: locationCode
                "\"RECEIPT_ID\" INTEGER NOT NULL ," + // 5: receiptId
                "\"BARCODE\" TEXT);"); // 6: barcode
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, ContainerInfo entity) {
        stmt.clearBindings();
        stmt.bindLong(1, entity.get_id());
        stmt.bindDouble(2, entity.getQty());
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(3, name);
        }
        stmt.bindLong(4, entity.getId());
 
        String locationCode = entity.getLocationCode();
        if (locationCode != null) {
            stmt.bindString(5, locationCode);
        }
        stmt.bindLong(6, entity.getReceiptId());
 
        String barcode = entity.getBarcode();
        if (barcode != null) {
            stmt.bindString(7, barcode);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, ContainerInfo entity) {
        stmt.clearBindings();
        stmt.bindLong(1, entity.get_id());
        stmt.bindDouble(2, entity.getQty());
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(3, name);
        }
        stmt.bindLong(4, entity.getId());
 
        String locationCode = entity.getLocationCode();
        if (locationCode != null) {
            stmt.bindString(5, locationCode);
        }
        stmt.bindLong(6, entity.getReceiptId());
 
        String barcode = entity.getBarcode();
        if (barcode != null) {
            stmt.bindString(7, barcode);
        }
    }

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

    @Override
    public ContainerInfo readEntity(Cursor cursor, int offset) {
        ContainerInfo entity = new ContainerInfo( //
            cursor.getLong(offset + 0), // _id
            cursor.getFloat(offset + 1), // qty
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // name
            cursor.getInt(offset + 3), // id
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // locationCode
            cursor.getInt(offset + 5), // receiptId
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6) // barcode
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, ContainerInfo entity, int offset) {
        entity.set_id(cursor.getLong(offset + 0));
        entity.setQty(cursor.getFloat(offset + 1));
        entity.setName(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setId(cursor.getInt(offset + 3));
        entity.setLocationCode(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setReceiptId(cursor.getInt(offset + 5));
        entity.setBarcode(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(ContainerInfo entity, long rowId) {
        entity.set_id(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(ContainerInfo entity) {
        if(entity != null) {
            return entity.get_id();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(ContainerInfo entity) {
        throw new UnsupportedOperationException("Unsupported for entities with a non-null key");
    }

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