mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
fixed table collection error
This commit is contained in:
parent
4e2e874c91
commit
b89ea85dad
@ -97,13 +97,6 @@ public class TableInfo {
|
|||||||
private List<UpdateListener> onUpdateListeners;
|
private List<UpdateListener> onUpdateListeners;
|
||||||
private List<SetListener> onSetListeners;
|
private List<SetListener> onSetListeners;
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 该功能有更好的方式实现,此属性可能会被移除。
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
private Map<String, Class<?>> joinTypes;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对应 MapperXML 配置文件中 {@code <resultMap>} 标签下的 {@code <association>} 标签。
|
* 对应 MapperXML 配置文件中 {@code <resultMap>} 标签下的 {@code <association>} 标签。
|
||||||
*/
|
*/
|
||||||
@ -297,21 +290,6 @@ public class TableInfo {
|
|||||||
return propertyColumnMapping.get(property);
|
return propertyColumnMapping.get(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Class<?>> getJoinTypes() {
|
|
||||||
return joinTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setJoinTypes(Map<String, Class<?>> joinTypes) {
|
|
||||||
this.joinTypes = joinTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addJoinType(String fieldName, Class<?> clazz) {
|
|
||||||
if (joinTypes == null) {
|
|
||||||
joinTypes = new HashMap<>();
|
|
||||||
}
|
|
||||||
joinTypes.put(fieldName, clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Class<?>> getAssociationType() {
|
public Map<String, Class<?>> getAssociationType() {
|
||||||
return associationType;
|
return associationType;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,7 +48,8 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class TableInfoFactory {
|
public class TableInfoFactory {
|
||||||
|
|
||||||
private TableInfoFactory() {}
|
private TableInfoFactory() {
|
||||||
|
}
|
||||||
|
|
||||||
private static final Set<Class<?>> defaultSupportColumnTypes = CollectionUtil.newHashSet(
|
private static final Set<Class<?>> defaultSupportColumnTypes = CollectionUtil.newHashSet(
|
||||||
int.class, Integer.class,
|
int.class, Integer.class,
|
||||||
@ -216,12 +217,15 @@ public class TableInfoFactory {
|
|||||||
if (Collection.class.isAssignableFrom(fieldType)) {
|
if (Collection.class.isAssignableFrom(fieldType)) {
|
||||||
ParameterizedType genericType = (ParameterizedType) field.getGenericType();
|
ParameterizedType genericType = (ParameterizedType) field.getGenericType();
|
||||||
Type actualTypeArgument = genericType.getActualTypeArguments()[0];
|
Type actualTypeArgument = genericType.getActualTypeArguments()[0];
|
||||||
tableInfo.addCollectionType(field, (Class<?>) actualTypeArgument);
|
|
||||||
|
//需排除 List<String> List<Long> 等场景
|
||||||
|
if (!defaultSupportColumnTypes.contains(actualTypeArgument)) {
|
||||||
|
tableInfo.addCollectionType(field, (Class<?>) actualTypeArgument);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 实体类嵌套
|
// 实体类嵌套
|
||||||
else if (!Map.class.isAssignableFrom(fieldType)
|
else if (!Map.class.isAssignableFrom(fieldType)
|
||||||
&& !fieldType.isArray()) {
|
&& !fieldType.isArray()) {
|
||||||
// tableInfo.addJoinType(field.getName(), fieldType);
|
|
||||||
tableInfo.addAssociationType(field.getName(), fieldType);
|
tableInfo.addAssociationType(field.getName(), fieldType);
|
||||||
}
|
}
|
||||||
// 不支持的类型直接跳过
|
// 不支持的类型直接跳过
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user