@@ -19,7 +19,7 @@ public class StandardSqlMaker implements SqlMaker {
19
19
20
20
private static ConcurrentHashMap <Class <?>, StandardPojoInfo > map = new ConcurrentHashMap <>();
21
21
22
- public StandardPojoInfo getPojoInfo (Class <?> rowClass ) {
22
+ public synchronized StandardPojoInfo getPojoInfo (Class <?> rowClass ) {
23
23
StandardPojoInfo pi = map .get (rowClass );
24
24
if (pi == null ) {
25
25
pi = new StandardPojoInfo (rowClass );
@@ -69,7 +69,7 @@ public Object[] getUpdateArgs(Query query, Object row) {
69
69
args [i ] = pojoInfo .getValue (row , pojoInfo .updateColumnNames [i ]);
70
70
}
71
71
// add the value for the where clause to the end
72
- for (int i = 0 ; i <numKeys ; i ++) {
72
+ for (int i = 0 ; i < numKeys ; i ++) {
73
73
Object pk = pojoInfo .getValue (row , pojoInfo .primaryKeyNames .get (i ));
74
74
args [pojoInfo .updateSqlArgCount - (numKeys - i )] = pk ;
75
75
}
@@ -92,7 +92,11 @@ public void makeUpdateSql(StandardPojoInfo pojoInfo) {
92
92
cols .add (prop .name );
93
93
}
94
94
pojoInfo .updateColumnNames = cols .toArray (new String [cols .size ()]);
95
- pojoInfo .updateSqlArgCount = pojoInfo .updateColumnNames .length + pojoInfo .primaryKeyNames .size (); // + # of primary keys for the where arg
95
+ pojoInfo .updateSqlArgCount = pojoInfo .updateColumnNames .length + pojoInfo .primaryKeyNames .size (); // + # of
96
+ // primary
97
+ // keys for
98
+ // the where
99
+ // arg
96
100
97
101
StringBuilder buf = new StringBuilder ();
98
102
buf .append ("update %s set " );
@@ -105,7 +109,7 @@ public void makeUpdateSql(StandardPojoInfo pojoInfo) {
105
109
}
106
110
buf .append (" where " );
107
111
108
- for (int i = 0 ; i < pojoInfo .primaryKeyNames .size (); i ++){
112
+ for (int i = 0 ; i < pojoInfo .primaryKeyNames .size (); i ++) {
109
113
if (i > 0 ) {
110
114
buf .append (" and " );
111
115
}
@@ -235,7 +239,7 @@ public String getCreateTableSql(Class<?> clazz) {
235
239
236
240
if (pojoInfo .primaryKeyNames .size () > 0 ) {
237
241
buf .append (", primary key (" );
238
- for (int i = 0 ; i < pojoInfo .primaryKeyNames .size (); i ++){
242
+ for (int i = 0 ; i < pojoInfo .primaryKeyNames .size (); i ++) {
239
243
if (i > 0 ) {
240
244
buf .append ("," );
241
245
}
@@ -295,7 +299,7 @@ public String getDeleteSql(Query query, Object row) {
295
299
296
300
StringBuilder builder = new StringBuilder ("delete from " );
297
301
builder .append (table ).append (" where " );
298
- for (int i = 0 ; i < pojoInfo .primaryKeyNames .size (); i ++){
302
+ for (int i = 0 ; i < pojoInfo .primaryKeyNames .size (); i ++) {
299
303
if (i > 0 ) {
300
304
builder .append (" and " );
301
305
}
@@ -310,7 +314,7 @@ public Object[] getDeleteArgs(Query query, Object row) {
310
314
StandardPojoInfo pojoInfo = getPojoInfo (row .getClass ());
311
315
Object [] args = new Object [pojoInfo .primaryKeyNames .size ()];
312
316
313
- for (int i = 0 ; i < pojoInfo .primaryKeyNames .size (); i ++) {
317
+ for (int i = 0 ; i < pojoInfo .primaryKeyNames .size (); i ++) {
314
318
Object primaryKeyValue = pojoInfo .getValue (row , pojoInfo .primaryKeyNames .get (i ));
315
319
args [i ] = primaryKeyValue ;
316
320
}
0 commit comments