SearchHistoryDao.java
3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package com.cmcc.migutvtwo.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.cmcc.migutvtwo.dao.SearchHistory;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table SEARCH_HISTORY.
*/
public class SearchHistoryDao extends AbstractDao<SearchHistory, Long> {
public static final String TABLENAME = "SEARCH_HISTORY";
/**
* Properties of entity SearchHistory.<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 Keyword = new Property(1, String.class, "keyword", false, "KEYWORD");
};
public SearchHistoryDao(DaoConfig config) {
super(config);
}
public SearchHistoryDao(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 + "'SEARCH_HISTORY' (" + //
"'ID' INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
"'KEYWORD' TEXT);"); // 1: keyword
}
/** Drops the underlying database table. */
public static void dropTable(SQLiteDatabase db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "'SEARCH_HISTORY'";
db.execSQL(sql);
}
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, SearchHistory entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
String keyword = entity.getKeyword();
if (keyword != null) {
stmt.bindString(2, keyword);
}
}
/** @inheritdoc */
@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
/** @inheritdoc */
@Override
public SearchHistory readEntity(Cursor cursor, int offset) {
SearchHistory entity = new SearchHistory( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1) // keyword
);
return entity;
}
/** @inheritdoc */
@Override
public void readEntity(Cursor cursor, SearchHistory entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setKeyword(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
}
/** @inheritdoc */
@Override
protected Long updateKeyAfterInsert(SearchHistory entity, long rowId) {
entity.setId(rowId);
return rowId;
}
/** @inheritdoc */
@Override
public Long getKey(SearchHistory entity) {
if(entity != null) {
return entity.getId();
} else {
return null;
}
}
/** @inheritdoc */
@Override
protected boolean isEntityUpdateable() {
return true;
}
}