WarringBeanDao.java 4.7 KB

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