package de.saxsys.android.projectiler.app.generatedmodel;
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 de.saxsys.android.projectiler.app.generatedmodel.Track;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table TRACK.
*/
public class TrackDao extends AbstractDao<Track, Long> {
public static final String TABLENAME = "TRACK";
/**
* Properties of entity Track.<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 ProjectName = new Property(1, String.class, "projectName", false, "PROJECT_NAME");
public final static Property Timestamp = new Property(2, java.util.Date.class, "timestamp", false, "TIMESTAMP");
public final static Property StartdDate = new Property(3, java.util.Date.class, "startdDate", false, "STARTD_DATE");
public final static Property EndDate = new Property(4, java.util.Date.class, "endDate", false, "END_DATE");
};
public TrackDao(DaoConfig config) {
super(config);
}
public TrackDao(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 + "'TRACK' (" + //
"'_id' INTEGER PRIMARY KEY ," + // 0: id
"'PROJECT_NAME' TEXT NOT NULL ," + // 1: projectName
"'TIMESTAMP' INTEGER NOT NULL ," + // 2: timestamp
"'STARTD_DATE' INTEGER NOT NULL ," + // 3: startdDate
"'END_DATE' INTEGER NOT NULL );"); // 4: endDate
}
/** Drops the underlying database table. */
public static void dropTable(SQLiteDatabase db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "'TRACK'";
db.execSQL(sql);
}
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, Track entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
stmt.bindString(2, entity.getProjectName());
stmt.bindLong(3, entity.getTimestamp().getTime());
stmt.bindLong(4, entity.getStartdDate().getTime());
stmt.bindLong(5, entity.getEndDate().getTime());
}
/** @inheritdoc */
@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
/** @inheritdoc */
@Override
public Track readEntity(Cursor cursor, int offset) {
Track entity = new Track( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.getString(offset + 1), // projectName
new java.util.Date(cursor.getLong(offset + 2)), // timestamp
new java.util.Date(cursor.getLong(offset + 3)), // startdDate
new java.util.Date(cursor.getLong(offset + 4)) // endDate
);
return entity;
}
/** @inheritdoc */
@Override
public void readEntity(Cursor cursor, Track entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setProjectName(cursor.getString(offset + 1));
entity.setTimestamp(new java.util.Date(cursor.getLong(offset + 2)));
entity.setStartdDate(new java.util.Date(cursor.getLong(offset + 3)));
entity.setEndDate(new java.util.Date(cursor.getLong(offset + 4)));
}
/** @inheritdoc */
@Override
protected Long updateKeyAfterInsert(Track entity, long rowId) {
entity.setId(rowId);
return rowId;
}
/** @inheritdoc */
@Override
public Long getKey(Track entity) {
if(entity != null) {
return entity.getId();
} else {
return null;
}
}
/** @inheritdoc */
@Override
protected boolean isEntityUpdateable() {
return true;
}
}