@@ -110,6 +110,7 @@ public static class EntityColumn {
110
110
private boolean uuid = false ;
111
111
private boolean identity = false ;
112
112
private String generator ;
113
+ private String keyProperties ;//useGenerator包含多列的时候需要用到
113
114
private String orderBy ;
114
115
115
116
public String getProperty () {
@@ -176,6 +177,14 @@ public void setGenerator(String generator) {
176
177
this .generator = generator ;
177
178
}
178
179
180
+ public String getKeyProperties () {
181
+ return keyProperties ;
182
+ }
183
+
184
+ public void setKeyProperties (String keyProperties ) {
185
+ this .keyProperties = keyProperties ;
186
+ }
187
+
179
188
public String getOrderBy () {
180
189
return orderBy ;
181
190
}
@@ -423,18 +432,10 @@ public static synchronized void initEntityNameMap(Class<?> entityClass) {
423
432
} else if (field .isAnnotationPresent (GeneratedValue .class )) {
424
433
GeneratedValue generatedValue = field .getAnnotation (GeneratedValue .class );
425
434
if (generatedValue .generator ().equals ("UUID" )) {
426
- if (field .getType ().equals (String .class )) {
427
- entityColumn .setUuid (true );
428
- } else {
429
- throw new RuntimeException (field .getName () + " - 该字段@GeneratedValue配置为UUID,但该字段类型不是String" );
430
- }
435
+ entityColumn .setUuid (true );
431
436
} else if (generatedValue .generator ().equals ("JDBC" )) {
432
- if (Number .class .isAssignableFrom (field .getType ())) {
433
- entityColumn .setIdentity (true );
434
- entityColumn .setGenerator ("JDBC" );
435
- } else {
436
- throw new RuntimeException (field .getName () + " - 该字段@GeneratedValue配置为UUID,但该字段类型不是String" );
437
- }
437
+ entityColumn .setIdentity (true );
438
+ entityColumn .setGenerator ("JDBC" );
438
439
} else {
439
440
//允许通过generator来设置获取id的sql,例如mysql=CALL IDENTITY(),hsqldb=SELECT SCOPE_IDENTITY()
440
441
//允许通过拦截器参数设置公共的generator
@@ -475,13 +476,6 @@ public static synchronized void initEntityNameMap(Class<?> entityClass) {
475
476
entityTableMap .put (entityClass , entityTable );
476
477
}
477
478
478
- public static void main (String [] args ) {
479
- System .out .println (camelhumpToUnderline ("userName" ));
480
- System .out .println (camelhumpToUnderline ("userPassWord" ));
481
- System .out .println (camelhumpToUnderline ("ISO9001" ));
482
- System .out .println (camelhumpToUnderline ("hello_world" ));
483
- }
484
-
485
479
/**
486
480
* 将驼峰风格替换为下划线风格
487
481
*/
0 commit comments