@@ -25,10 +25,11 @@ public class UserDao extends AbstractDao<User, Long> {
25
25
*/
26
26
public static class Properties {
27
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 Age = new Property (2 , String .class , "age" , false , "AGE" );
30
- public final static Property Sex = new Property (3 , String .class , "sex" , false , "SEX" );
31
- public final static Property Salary = new Property (4 , String .class , "salary" , false , "SALARY" );
28
+ public final static Property Userid = new Property (1 , String .class , "userid" , false , "USERID" );
29
+ public final static Property Name = new Property (2 , String .class , "name" , false , "NAME" );
30
+ public final static Property Age = new Property (3 , String .class , "age" , false , "AGE" );
31
+ public final static Property Sex = new Property (4 , String .class , "sex" , false , "SEX" );
32
+ public final static Property Salary = new Property (5 , String .class , "salary" , false , "SALARY" );
32
33
};
33
34
34
35
@@ -45,10 +46,11 @@ public static void createTable(Database db, boolean ifNotExists) {
45
46
String constraint = ifNotExists ? "IF NOT EXISTS " : "" ;
46
47
db .execSQL ("CREATE TABLE " + constraint + "\" USER\" (" + //
47
48
"\" _id\" INTEGER PRIMARY KEY ," + // 0: id
48
- "\" NAME\" TEXT," + // 1: name
49
- "\" AGE\" TEXT," + // 2: age
50
- "\" SEX\" TEXT," + // 3: sex
51
- "\" SALARY\" TEXT);" ); // 4: salary
49
+ "\" USERID\" TEXT," + // 1: userid
50
+ "\" NAME\" TEXT," + // 2: name
51
+ "\" AGE\" TEXT," + // 3: age
52
+ "\" SEX\" TEXT," + // 4: sex
53
+ "\" SALARY\" TEXT);" ); // 5: salary
52
54
}
53
55
54
56
/** Drops the underlying database table. */
@@ -66,24 +68,29 @@ protected final void bindValues(DatabaseStatement stmt, User entity) {
66
68
stmt .bindLong (1 , id );
67
69
}
68
70
71
+ String userid = entity .getUserid ();
72
+ if (userid != null ) {
73
+ stmt .bindString (2 , userid );
74
+ }
75
+
69
76
String name = entity .getName ();
70
77
if (name != null ) {
71
- stmt .bindString (2 , name );
78
+ stmt .bindString (3 , name );
72
79
}
73
80
74
81
String age = entity .getAge ();
75
82
if (age != null ) {
76
- stmt .bindString (3 , age );
83
+ stmt .bindString (4 , age );
77
84
}
78
85
79
86
String sex = entity .getSex ();
80
87
if (sex != null ) {
81
- stmt .bindString (4 , sex );
88
+ stmt .bindString (5 , sex );
82
89
}
83
90
84
91
String salary = entity .getSalary ();
85
92
if (salary != null ) {
86
- stmt .bindString (5 , salary );
93
+ stmt .bindString (6 , salary );
87
94
}
88
95
}
89
96
@@ -96,24 +103,29 @@ protected final void bindValues(SQLiteStatement stmt, User entity) {
96
103
stmt .bindLong (1 , id );
97
104
}
98
105
106
+ String userid = entity .getUserid ();
107
+ if (userid != null ) {
108
+ stmt .bindString (2 , userid );
109
+ }
110
+
99
111
String name = entity .getName ();
100
112
if (name != null ) {
101
- stmt .bindString (2 , name );
113
+ stmt .bindString (3 , name );
102
114
}
103
115
104
116
String age = entity .getAge ();
105
117
if (age != null ) {
106
- stmt .bindString (3 , age );
118
+ stmt .bindString (4 , age );
107
119
}
108
120
109
121
String sex = entity .getSex ();
110
122
if (sex != null ) {
111
- stmt .bindString (4 , sex );
123
+ stmt .bindString (5 , sex );
112
124
}
113
125
114
126
String salary = entity .getSalary ();
115
127
if (salary != null ) {
116
- stmt .bindString (5 , salary );
128
+ stmt .bindString (6 , salary );
117
129
}
118
130
}
119
131
@@ -126,21 +138,23 @@ public Long readKey(Cursor cursor, int offset) {
126
138
public User readEntity (Cursor cursor , int offset ) {
127
139
User entity = new User ( //
128
140
cursor .isNull (offset + 0 ) ? null : cursor .getLong (offset + 0 ), // id
129
- cursor .isNull (offset + 1 ) ? null : cursor .getString (offset + 1 ), // name
130
- cursor .isNull (offset + 2 ) ? null : cursor .getString (offset + 2 ), // age
131
- cursor .isNull (offset + 3 ) ? null : cursor .getString (offset + 3 ), // sex
132
- cursor .isNull (offset + 4 ) ? null : cursor .getString (offset + 4 ) // salary
141
+ cursor .isNull (offset + 1 ) ? null : cursor .getString (offset + 1 ), // userid
142
+ cursor .isNull (offset + 2 ) ? null : cursor .getString (offset + 2 ), // name
143
+ cursor .isNull (offset + 3 ) ? null : cursor .getString (offset + 3 ), // age
144
+ cursor .isNull (offset + 4 ) ? null : cursor .getString (offset + 4 ), // sex
145
+ cursor .isNull (offset + 5 ) ? null : cursor .getString (offset + 5 ) // salary
133
146
);
134
147
return entity ;
135
148
}
136
149
137
150
@ Override
138
151
public void readEntity (Cursor cursor , User entity , int offset ) {
139
152
entity .setId (cursor .isNull (offset + 0 ) ? null : cursor .getLong (offset + 0 ));
140
- entity .setName (cursor .isNull (offset + 1 ) ? null : cursor .getString (offset + 1 ));
141
- entity .setAge (cursor .isNull (offset + 2 ) ? null : cursor .getString (offset + 2 ));
142
- entity .setSex (cursor .isNull (offset + 3 ) ? null : cursor .getString (offset + 3 ));
143
- entity .setSalary (cursor .isNull (offset + 4 ) ? null : cursor .getString (offset + 4 ));
153
+ entity .setUserid (cursor .isNull (offset + 1 ) ? null : cursor .getString (offset + 1 ));
154
+ entity .setName (cursor .isNull (offset + 2 ) ? null : cursor .getString (offset + 2 ));
155
+ entity .setAge (cursor .isNull (offset + 3 ) ? null : cursor .getString (offset + 3 ));
156
+ entity .setSex (cursor .isNull (offset + 4 ) ? null : cursor .getString (offset + 4 ));
157
+ entity .setSalary (cursor .isNull (offset + 5 ) ? null : cursor .getString (offset + 5 ));
144
158
}
145
159
146
160
@ Override
0 commit comments