package com.lean56.andplug.app.dao;
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.lean56.andplug.app.dao.Msg;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table MSG.
*/
public class MsgDao extends AbstractDao<Msg, Long> {
public static final String TABLENAME = "MSG";
/**
* Properties of entity Msg.<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 Title = new Property(1, String.class, "title", false, "TITLE");
public final static Property User = new Property(2, String.class, "user", false, "USER");
public final static Property Content = new Property(3, String.class, "content", false, "CONTENT");
};
public MsgDao(DaoConfig config) {
super(config);
}
public MsgDao(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 + "'MSG' (" + //
"'ID' INTEGER PRIMARY KEY ," + // 0: id
"'TITLE' TEXT," + // 1: title
"'USER' TEXT," + // 2: user
"'CONTENT' TEXT);"); // 3: content
}
/** Drops the underlying database table. */
public static void dropTable(SQLiteDatabase db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "'MSG'";
db.execSQL(sql);
}
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, Msg entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
String title = entity.getTitle();
if (title != null) {
stmt.bindString(2, title);
}
String user = entity.getUser();
if (user != null) {
stmt.bindString(3, user);
}
String content = entity.getContent();
if (content != null) {
stmt.bindString(4, content);
}
}
/** @inheritdoc */
@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
/** @inheritdoc */
@Override
public Msg readEntity(Cursor cursor, int offset) {
Msg entity = new Msg( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // title
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // user
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3) // content
);
return entity;
}
/** @inheritdoc */
@Override
public void readEntity(Cursor cursor, Msg entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setTitle(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
entity.setUser(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
entity.setContent(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
}
/** @inheritdoc */
@Override
protected Long updateKeyAfterInsert(Msg entity, long rowId) {
entity.setId(rowId);
return rowId;
}
/** @inheritdoc */
@Override
public Long getKey(Msg entity) {
if(entity != null) {
return entity.getId();
} else {
return null;
}
}
/** @inheritdoc */
@Override
protected boolean isEntityUpdateable() {
return true;
}
}