package com.gingersoft.gsa.cloud.database.greendao;

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.gingersoft.gsa.cloud.database.bean.FoodCombo;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "FOOD_COMBO".
*/
public class FoodComboDao extends AbstractDao<FoodCombo, Void> {

    public static final String TABLENAME = "FOOD_COMBO";

    /**
     * Properties of entity FoodCombo.<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", false, "_id");
        public final static Property Fid = new Property(1, Long.class, "fid", false, "FID");
        public final static Property ComId = new Property(2, int.class, "comId", false, "COM_ID");
    }


    public FoodComboDao(DaoConfig config) {
        super(config);
    }
    
    public FoodComboDao(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 + "\"FOOD_COMBO\" (" + //
                "\"_id\" INTEGER," + // 0: id
                "\"FID\" INTEGER," + // 1: fid
                "\"COM_ID\" INTEGER NOT NULL );"); // 2: comId
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, FoodCombo entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        Long fid = entity.getFid();
        if (fid != null) {
            stmt.bindLong(2, fid);
        }
        stmt.bindLong(3, entity.getComId());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, FoodCombo entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        Long fid = entity.getFid();
        if (fid != null) {
            stmt.bindLong(2, fid);
        }
        stmt.bindLong(3, entity.getComId());
    }

    @Override
    public Void readKey(Cursor cursor, int offset) {
        return null;
    }    

    @Override
    public FoodCombo readEntity(Cursor cursor, int offset) {
        FoodCombo entity = new FoodCombo( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // fid
            cursor.getInt(offset + 2) // comId
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, FoodCombo entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setFid(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
        entity.setComId(cursor.getInt(offset + 2));
     }
    
    @Override
    protected final Void updateKeyAfterInsert(FoodCombo entity, long rowId) {
        // Unsupported or missing PK type
        return null;
    }
    
    @Override
    public Void getKey(FoodCombo entity) {
        return null;
    }

    @Override
    public boolean hasKey(FoodCombo entity) {
        // TODO
        return false;
    }

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