package com.zlm.hp.db.dao;

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.zlm.hp.entity.SingerInfo;

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

    public static final String TABLENAME = "SINGER_INFO";

    /**
     * Properties of entity SingerInfo.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property SingerId = new Property(0, String.class, "singerId", false, "SINGER_ID");
        public final static Property SingerName = new Property(1, String.class, "singerName", false, "SINGER_NAME");
        public final static Property ImageUrl = new Property(2, String.class, "imageUrl", false, "IMAGE_URL");
        public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME");
    }


    public SingerInfoDao(DaoConfig config) {
        super(config);
    }
    
    public SingerInfoDao(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 + "\"SINGER_INFO\" (" + //
                "\"SINGER_ID\" TEXT," + // 0: singerId
                "\"SINGER_NAME\" TEXT," + // 1: singerName
                "\"IMAGE_URL\" TEXT," + // 2: imageUrl
                "\"CREATE_TIME\" TEXT);"); // 3: createTime
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, SingerInfo entity) {
        stmt.clearBindings();
 
        String singerId = entity.getSingerId();
        if (singerId != null) {
            stmt.bindString(1, singerId);
        }
 
        String singerName = entity.getSingerName();
        if (singerName != null) {
            stmt.bindString(2, singerName);
        }
 
        String imageUrl = entity.getImageUrl();
        if (imageUrl != null) {
            stmt.bindString(3, imageUrl);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(4, createTime);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, SingerInfo entity) {
        stmt.clearBindings();
 
        String singerId = entity.getSingerId();
        if (singerId != null) {
            stmt.bindString(1, singerId);
        }
 
        String singerName = entity.getSingerName();
        if (singerName != null) {
            stmt.bindString(2, singerName);
        }
 
        String imageUrl = entity.getImageUrl();
        if (imageUrl != null) {
            stmt.bindString(3, imageUrl);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(4, createTime);
        }
    }

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

    @Override
    public SingerInfo readEntity(Cursor cursor, int offset) {
        SingerInfo entity = new SingerInfo();
        readEntity(cursor, entity, offset);
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, SingerInfo entity, int offset) {
        entity.setSingerId(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
        entity.setSingerName(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setImageUrl(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
     }
    
    @Override
    protected final Void updateKeyAfterInsert(SingerInfo entity, long rowId) {
        // Unsupported or missing PK type
        return null;
    }
    
    @Override
    public Void getKey(SingerInfo entity) {
        return null;
    }

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

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