支持通过FlexConfiguration预注册的自定义typeHandler,同时解决需要带自定义初始化参数的问题

This commit is contained in:
tanglh 2024-02-02 23:42:29 +08:00
parent 3330a417a9
commit 8dd5578d15

View File

@ -435,7 +435,12 @@ public class TableInfoFactory {
Class<?> typeHandlerClass = columnAnnotation.typeHandler(); Class<?> typeHandlerClass = columnAnnotation.typeHandler();
Configuration configuration = FlexGlobalConfig.getDefaultConfig().getConfiguration(); Configuration configuration = FlexGlobalConfig.getDefaultConfig().getConfiguration();
TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry(); TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
typeHandler = typeHandlerRegistry.getInstance(columnInfo.getPropertyType(), typeHandlerClass); Class<?> propertyType = columnInfo.getPropertyType();
JdbcType jdbcType = columnAnnotation.jdbcType();
typeHandler = typeHandlerRegistry.getTypeHandler(propertyType, jdbcType);
if (typeHandler == null || !typeHandlerClass.isAssignableFrom(typeHandler.getClass())) {
typeHandler = typeHandlerRegistry.getInstance(propertyType, typeHandlerClass);
}
} }
columnInfo.setTypeHandler(typeHandler); columnInfo.setTypeHandler(typeHandler);