fixed register typeHandler

This commit is contained in:
开源海哥 2023-03-15 14:09:24 +08:00
parent 45d15c96df
commit 8f359c9399

View File

@ -199,17 +199,13 @@ public class TableInfos {
columnInfo.setPropertyType(field.getType()); columnInfo.setPropertyType(field.getType());
if (column != null && column.typeHandler() != UnknownTypeHandler.class) { if (column != null && column.typeHandler() != UnknownTypeHandler.class) {
Class<? extends TypeHandler> typeHandlerClass = column.typeHandler(); Class<?> typeHandlerClass = column.typeHandler();
Configuration configuration = FlexGlobalConfig.getDefaultConfig().getConfiguration(); Configuration configuration = FlexGlobalConfig.getDefaultConfig().getConfiguration();
TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry(); TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
if (!typeHandlerRegistry.hasTypeHandler(typeHandlerClass)) { TypeHandler<?> typeHandler = typeHandlerRegistry.getInstance(columnInfo.getPropertyType(), typeHandlerClass);
typeHandlerRegistry.register(typeHandlerClass);
}
TypeHandler<? extends TypeHandler> typeHandler = typeHandlerRegistry.getTypeHandler(typeHandlerClass);
columnInfo.setTypeHandler(typeHandler); columnInfo.setTypeHandler(typeHandler);
} }
if (column != null && column.jdbcType() != JdbcType.UNDEFINED) { if (column != null && column.jdbcType() != JdbcType.UNDEFINED) {
columnInfo.setJdbcType(column.jdbcType()); columnInfo.setJdbcType(column.jdbcType());
} }