|
| 1 | +package com.carlos.grabredenvelope.db; |
| 2 | + |
| 3 | +import android.database.Cursor; |
| 4 | +import android.database.sqlite.SQLiteStatement; |
| 5 | + |
| 6 | +import org.greenrobot.greendao.AbstractDao; |
| 7 | +import org.greenrobot.greendao.Property; |
| 8 | +import org.greenrobot.greendao.internal.DaoConfig; |
| 9 | +import org.greenrobot.greendao.database.Database; |
| 10 | +import org.greenrobot.greendao.database.DatabaseStatement; |
| 11 | + |
| 12 | +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. |
| 13 | +/** |
| 14 | + * DAO for table "WECHAT_RED_ENVELOPE". |
| 15 | +*/ |
| 16 | +public class WechatRedEnvelopeDao extends AbstractDao<WechatRedEnvelope, Long> { |
| 17 | + |
| 18 | + public static final String TABLENAME = "WECHAT_RED_ENVELOPE"; |
| 19 | + |
| 20 | + /** |
| 21 | + * Properties of entity WechatRedEnvelope.<br/> |
| 22 | + * Can be used for QueryBuilder and for referencing column names. |
| 23 | + */ |
| 24 | + public static class Properties { |
| 25 | + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); |
| 26 | + public final static Property Time = new Property(1, long.class, "time", false, "TIME"); |
| 27 | + public final static Property Count = new Property(2, String.class, "count", false, "COUNT"); |
| 28 | + } |
| 29 | + |
| 30 | + |
| 31 | + public WechatRedEnvelopeDao(DaoConfig config) { |
| 32 | + super(config); |
| 33 | + } |
| 34 | + |
| 35 | + public WechatRedEnvelopeDao(DaoConfig config, DaoSession daoSession) { |
| 36 | + super(config, daoSession); |
| 37 | + } |
| 38 | + |
| 39 | + /** Creates the underlying database table. */ |
| 40 | + public static void createTable(Database db, boolean ifNotExists) { |
| 41 | + String constraint = ifNotExists? "IF NOT EXISTS ": ""; |
| 42 | + db.execSQL("CREATE TABLE " + constraint + "\"WECHAT_RED_ENVELOPE\" (" + // |
| 43 | + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id |
| 44 | + "\"TIME\" INTEGER NOT NULL ," + // 1: time |
| 45 | + "\"COUNT\" TEXT);"); // 2: count |
| 46 | + } |
| 47 | + |
| 48 | + /** Drops the underlying database table. */ |
| 49 | + public static void dropTable(Database db, boolean ifExists) { |
| 50 | + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"WECHAT_RED_ENVELOPE\""; |
| 51 | + db.execSQL(sql); |
| 52 | + } |
| 53 | + |
| 54 | + @Override |
| 55 | + protected final void bindValues(DatabaseStatement stmt, WechatRedEnvelope entity) { |
| 56 | + stmt.clearBindings(); |
| 57 | + |
| 58 | + Long id = entity.getId(); |
| 59 | + if (id != null) { |
| 60 | + stmt.bindLong(1, id); |
| 61 | + } |
| 62 | + stmt.bindLong(2, entity.getTime()); |
| 63 | + |
| 64 | + String count = entity.getCount(); |
| 65 | + if (count != null) { |
| 66 | + stmt.bindString(3, count); |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + @Override |
| 71 | + protected final void bindValues(SQLiteStatement stmt, WechatRedEnvelope entity) { |
| 72 | + stmt.clearBindings(); |
| 73 | + |
| 74 | + Long id = entity.getId(); |
| 75 | + if (id != null) { |
| 76 | + stmt.bindLong(1, id); |
| 77 | + } |
| 78 | + stmt.bindLong(2, entity.getTime()); |
| 79 | + |
| 80 | + String count = entity.getCount(); |
| 81 | + if (count != null) { |
| 82 | + stmt.bindString(3, count); |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + @Override |
| 87 | + public Long readKey(Cursor cursor, int offset) { |
| 88 | + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); |
| 89 | + } |
| 90 | + |
| 91 | + @Override |
| 92 | + public WechatRedEnvelope readEntity(Cursor cursor, int offset) { |
| 93 | + WechatRedEnvelope entity = new WechatRedEnvelope( // |
| 94 | + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id |
| 95 | + cursor.getLong(offset + 1), // time |
| 96 | + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2) // count |
| 97 | + ); |
| 98 | + return entity; |
| 99 | + } |
| 100 | + |
| 101 | + @Override |
| 102 | + public void readEntity(Cursor cursor, WechatRedEnvelope entity, int offset) { |
| 103 | + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); |
| 104 | + entity.setTime(cursor.getLong(offset + 1)); |
| 105 | + entity.setCount(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); |
| 106 | + } |
| 107 | + |
| 108 | + @Override |
| 109 | + protected final Long updateKeyAfterInsert(WechatRedEnvelope entity, long rowId) { |
| 110 | + entity.setId(rowId); |
| 111 | + return rowId; |
| 112 | + } |
| 113 | + |
| 114 | + @Override |
| 115 | + public Long getKey(WechatRedEnvelope entity) { |
| 116 | + if(entity != null) { |
| 117 | + return entity.getId(); |
| 118 | + } else { |
| 119 | + return null; |
| 120 | + } |
| 121 | + } |
| 122 | + |
| 123 | + @Override |
| 124 | + public boolean hasKey(WechatRedEnvelope entity) { |
| 125 | + return entity.getId() != null; |
| 126 | + } |
| 127 | + |
| 128 | + @Override |
| 129 | + protected final boolean isEntityUpdateable() { |
| 130 | + return true; |
| 131 | + } |
| 132 | + |
| 133 | +} |
0 commit comments