mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
fixed: codegen error for "blob" type
This commit is contained in:
parent
8bfdf1c0f6
commit
c2ee7cf042
@ -38,7 +38,10 @@ public abstract class JdbcDialect implements IDialect {
|
|||||||
for (int i = 1; i <= columnCount; i++) {
|
for (int i = 1; i <= columnCount; i++) {
|
||||||
Column column = new Column();
|
Column column = new Column();
|
||||||
column.setName(columnMetaData.getColumnName(i));
|
column.setName(columnMetaData.getColumnName(i));
|
||||||
column.setPropertyType(columnMetaData.getColumnClassName(i));
|
|
||||||
|
String jdbcType = columnMetaData.getColumnClassName(i);
|
||||||
|
column.setPropertyType(JdbcTypeMapping.getType(jdbcType));
|
||||||
|
|
||||||
column.setAutoIncrement(columnMetaData.isAutoIncrement(i));
|
column.setAutoIncrement(columnMetaData.isAutoIncrement(i));
|
||||||
|
|
||||||
//注释
|
//注释
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.mybatisflex.codegen.dialect;
|
||||||
|
|
||||||
|
import com.mybatisflex.core.util.StringUtil;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class JdbcTypeMapping {
|
||||||
|
|
||||||
|
private static Map<String, String> mapping = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
mapping.put("[B", "byte[]");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerMapping(Class<?> from, Class<?> to) {
|
||||||
|
mapping.put(from.getName(), to.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerMapping(String from, String to) {
|
||||||
|
mapping.put(from, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
static String getType(String jdbcType) {
|
||||||
|
String registered = mapping.get(jdbcType);
|
||||||
|
return StringUtil.isNotBlank(registered) ? registered : jdbcType;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -203,7 +203,10 @@ public class Column {
|
|||||||
List<String> importClasses = new ArrayList<>();
|
List<String> importClasses = new ArrayList<>();
|
||||||
|
|
||||||
//lang 包不需要显式导入
|
//lang 包不需要显式导入
|
||||||
if (!propertyType.startsWith("java.lang.")) {
|
if (!propertyType.startsWith("java.lang.")
|
||||||
|
&& !"byte[]".equals(propertyType)
|
||||||
|
&& !"Byte[]".equals(propertyType)
|
||||||
|
) {
|
||||||
importClasses.add(propertyType);
|
importClasses.add(propertyType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user