feature:add jdbcType config support

This commit is contained in:
开源海哥 2023-03-15 11:11:58 +08:00
parent ab4bc2d8c5
commit 9fc1ca1ca2
2 changed files with 9 additions and 1 deletions

View File

@ -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;

View File

@ -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;
}