From 8dd5578d153fb478d54382ccd1d44220d053069a Mon Sep 17 00:00:00 2001 From: tanglh Date: Fri, 2 Feb 2024 23:42:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=80=9A=E8=BF=87FlexConfigu?= =?UTF-8?q?ration=E9=A2=84=E6=B3=A8=E5=86=8C=E7=9A=84=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89typeHandler=EF=BC=8C=E5=90=8C=E6=97=B6=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E9=9C=80=E8=A6=81=E5=B8=A6=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=8F=82=E6=95=B0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mybatisflex/core/table/TableInfoFactory.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfoFactory.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfoFactory.java index 5cf8d1d8..cf5aafcb 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfoFactory.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfoFactory.java @@ -435,7 +435,12 @@ public class TableInfoFactory { Class typeHandlerClass = columnAnnotation.typeHandler(); Configuration configuration = FlexGlobalConfig.getDefaultConfig().getConfiguration(); 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);