From 9fc1ca1ca2ecdff9c52731e2d3f2e4a72a120060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=80=E6=BA=90=E6=B5=B7=E5=93=A5?= Date: Wed, 15 Mar 2023 11:11:58 +0800 Subject: [PATCH] =?UTF-8?q?feature=EF=BC=9Aadd=20jdbcType=20config=20suppo?= =?UTF-8?q?rt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/mybatisflex/core/table/TableInfo.java | 4 +++- .../main/java/com/mybatisflex/core/table/TableInfos.java | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfo.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfo.java index b05e65a0..0e09d66c 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfo.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfo.java @@ -432,6 +432,7 @@ public class TableInfo { for (ColumnInfo columnInfo : columnInfoList) { ResultMapping mapping = new ResultMapping.Builder(configuration, columnInfo.getProperty(), columnInfo.getColumn(), columnInfo.getPropertyType()) + .jdbcType(columnInfo.getJdbcType()) .typeHandler(columnInfo.getTypeHandler()) .build(); resultMappings.add(mapping); @@ -441,6 +442,7 @@ public class TableInfo { ResultMapping mapping = new ResultMapping.Builder(configuration, idInfo.getProperty(), idInfo.getColumn(), idInfo.getPropertyType()) .flags(CollectionUtil.newArrayList(ResultFlag.ID)) + .jdbcType(idInfo.getJdbcType()) .typeHandler(idInfo.getTypeHandler()) .build(); resultMappings.add(mapping); @@ -456,7 +458,7 @@ public class TableInfo { TypeHandler typeHandler = columnInfo.getTypeHandler(); if (value != null && typeHandler != null) { - return new TypeHandlerObject(typeHandler, value, columnInfo.jdbcType); + return new TypeHandlerObject(typeHandler, value, columnInfo.getJdbcType()); } return value; diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfos.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfos.java index 87af9c69..6d123d63 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfos.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfos.java @@ -26,6 +26,7 @@ import com.mybatisflex.core.util.CollectionUtil; import com.mybatisflex.core.util.StringUtil; import org.apache.ibatis.reflection.Reflector; import org.apache.ibatis.session.Configuration; +import org.apache.ibatis.type.JdbcType; import org.apache.ibatis.type.TypeHandler; import org.apache.ibatis.type.TypeHandlerRegistry; import org.apache.ibatis.type.UnknownTypeHandler; @@ -204,6 +205,11 @@ public class TableInfos { columnInfo.setTypeHandler(typeHandler); } + + if (column != null && column.jdbcType() != JdbcType.UNDEFINED){ + columnInfo.setJdbcType(column.jdbcType()); + } + if (FlexConsts.DEFAULT_PRIMARY_FIELD.equals(field.getName())) { idField = field; }