Skip to content

Commit 3620ff9

Browse files
committed
修复枚举数组解析错误问题 hs-web#150
1 parent 50e6fc1 commit 3620ff9

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/builder/EasyOrmSqlBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ public Object getData(Object value) {
258258
} else if (column.getJavaType() == boolean.class || column.getJavaType() == Boolean.class) {
259259
column.setValueConverter(new BooleanValueConverter(column.getJdbcType()));
260260
column.setProperty("typeHandler", NumberBooleanTypeHandler.class.getName());
261-
} else if (column.getJavaType().isEnum()) {
261+
} else if (column.getJavaType().isEnum() || (
262+
column.getJavaType().isArray() && column.getJavaType().getComponentType().isEnum())) {
262263
//ignore
263264
} else if (TypeUtils.isNumberType(column)) { //数字
264265
//数字

hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/builder/jpa/JpaAnnotationParser.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,16 @@ public class JpaAnnotationParser {
8989
});
9090

9191
jdbcTypeConvert.add((type, property) -> {
92-
boolean isArray = type.isArray();
92+
Class<?> propertyType = property.getPropertyType();
93+
boolean isArray = propertyType.isArray();
9394
if (isArray) {
94-
type = type.getComponentType();
95-
95+
propertyType = propertyType.getComponentType();
9696
}
97-
if (type.isEnum() && EnumDict.class.isAssignableFrom(type)) {
98-
Class genType = ClassUtils.getGenericType(type);
97+
if (propertyType.isEnum() && EnumDict.class.isAssignableFrom(propertyType)) {
9998
if (isArray) {
10099
return JDBCType.BIGINT;
101100
}
101+
Class<?> genType = ((EnumDict<?>) propertyType.getEnumConstants()[0]).getValue().getClass();
102102
return jdbcTypeMapping.getOrDefault(genType, JDBCType.VARCHAR);
103103
}
104104
return null;

0 commit comments

Comments
 (0)