package com.pinecone.technology.mcommerce.learning.android.chapter06.example.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.pinecone.technology.mcommerce.learning.android.chapter06.example.dao.Employee; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. /** * DAO for table EMPLOYEE. */ public class EmployeeDao extends AbstractDao<Employee, Long> { public static final String TABLENAME = "EMPLOYEE"; /** * Properties of entity Employee.<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, "EmployeeId"); public final static Property LastName = new Property(1, String.class, "LastName", false, "LastName"); public final static Property FirstName = new Property(2, String.class, "FirstName", false, "FirstName"); public final static Property Title = new Property(3, String.class, "Title", false, "Title"); public final static Property ReportsTo = new Property(4, Long.class, "ReportsTo", false, "ReportsTo"); public final static Property BirthDate = new Property(5, java.util.Date.class, "BirthDate", false, "BirthDate"); public final static Property HireDate = new Property(6, java.util.Date.class, "HireDate", false, "HireDate"); public final static Property Address = new Property(7, String.class, "Address", false, "Address"); public final static Property City = new Property(8, String.class, "City", false, "City"); public final static Property State = new Property(9, String.class, "State", false, "State"); public final static Property Country = new Property(10, String.class, "Country", false, "Country"); public final static Property PostalCode = new Property(11, String.class, "PostalCode", false, "PostalCode"); public final static Property Phone = new Property(12, String.class, "Phone", false, "Phone"); public final static Property Fax = new Property(13, String.class, "Fax", false, "Fax"); public final static Property Email = new Property(14, String.class, "Email", false, "Email"); }; public EmployeeDao(DaoConfig config) { super(config); } public EmployeeDao(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 + "'EMPLOYEE' (" + // "'EmployeeId' INTEGER PRIMARY KEY ," + // 0: id "'LastName' NVARCHAR NOT NULL ," + // 1: LastName "'FirstName' NVARCHAR NOT NULL ," + // 2: FirstName "'Title' NVARCHAR NOT NULL ," + // 3: Title "'ReportsTo' INTEGER," + // 4: ReportsTo "'BirthDate' DATATIME," + // 5: BirthDate "'HireDate' DATATIME," + // 6: HireDate "'Address' NVARCHAR," + // 7: Address "'City' NVARCHAR," + // 8: City "'State' NVARCHAR," + // 9: State "'Country' NVARCHAR," + // 10: Country "'PostalCode' NVARCHAR," + // 11: PostalCode "'Phone' NVARCHAR," + // 12: Phone "'Fax' NVARCHAR," + // 13: Fax "'Email' NVARCHAR);"); // 14: Email } /** Drops the underlying database table. */ public static void dropTable(SQLiteDatabase db, boolean ifExists) { String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "'EMPLOYEE'"; db.execSQL(sql); } /** @inheritdoc */ @Override protected void bindValues(SQLiteStatement stmt, Employee entity) { stmt.clearBindings(); Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id); } stmt.bindString(2, entity.getLastName()); stmt.bindString(3, entity.getFirstName()); stmt.bindString(4, entity.getTitle()); Long ReportsTo = entity.getReportsTo(); if (ReportsTo != null) { stmt.bindLong(5, ReportsTo); } java.util.Date BirthDate = entity.getBirthDate(); if (BirthDate != null) { stmt.bindLong(6, BirthDate.getTime()); } java.util.Date HireDate = entity.getHireDate(); if (HireDate != null) { stmt.bindLong(7, HireDate.getTime()); } String Address = entity.getAddress(); if (Address != null) { stmt.bindString(8, Address); } String City = entity.getCity(); if (City != null) { stmt.bindString(9, City); } String State = entity.getState(); if (State != null) { stmt.bindString(10, State); } String Country = entity.getCountry(); if (Country != null) { stmt.bindString(11, Country); } String PostalCode = entity.getPostalCode(); if (PostalCode != null) { stmt.bindString(12, PostalCode); } String Phone = entity.getPhone(); if (Phone != null) { stmt.bindString(13, Phone); } String Fax = entity.getFax(); if (Fax != null) { stmt.bindString(14, Fax); } String Email = entity.getEmail(); if (Email != null) { stmt.bindString(15, Email); } } /** @inheritdoc */ @Override public Long readKey(Cursor cursor, int offset) { return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); } /** @inheritdoc */ @Override public Employee readEntity(Cursor cursor, int offset) { Employee entity = new Employee( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id cursor.getString(offset + 1), // LastName cursor.getString(offset + 2), // FirstName cursor.getString(offset + 3), // Title cursor.isNull(offset + 4) ? null : cursor.getLong(offset + 4), // ReportsTo cursor.isNull(offset + 5) ? null : new java.util.Date(cursor.getLong(offset + 5)), // BirthDate cursor.isNull(offset + 6) ? null : new java.util.Date(cursor.getLong(offset + 6)), // HireDate cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // Address cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // City cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // State cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // Country cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // PostalCode cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // Phone cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // Fax cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14) // Email ); return entity; } /** @inheritdoc */ @Override public void readEntity(Cursor cursor, Employee entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); entity.setLastName(cursor.getString(offset + 1)); entity.setFirstName(cursor.getString(offset + 2)); entity.setTitle(cursor.getString(offset + 3)); entity.setReportsTo(cursor.isNull(offset + 4) ? null : cursor.getLong(offset + 4)); entity.setBirthDate(cursor.isNull(offset + 5) ? null : new java.util.Date(cursor.getLong(offset + 5))); entity.setHireDate(cursor.isNull(offset + 6) ? null : new java.util.Date(cursor.getLong(offset + 6))); entity.setAddress(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); entity.setCity(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); entity.setState(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); entity.setCountry(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); entity.setPostalCode(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); entity.setPhone(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12)); entity.setFax(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13)); entity.setEmail(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); } /** @inheritdoc */ @Override protected Long updateKeyAfterInsert(Employee entity, long rowId) { entity.setId(rowId); return rowId; } /** @inheritdoc */ @Override public Long getKey(Employee entity) { if(entity != null) { return entity.getId(); } else { return null; } } /** @inheritdoc */ @Override protected boolean isEntityUpdateable() { return true; } }