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