修复在某些极端的情况下,由于 MappedStatement 缓存造成的类型转换异常的问题

This commit is contained in:
开源海哥 2023-07-03 16:40:59 +08:00
parent dd60479c4c
commit 6d452b0c06

View File

@ -54,7 +54,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class FlexConfiguration extends Configuration {
private static Map<Class<?>, MappedStatement> dynamicMappedStatementCache = new ConcurrentHashMap<>();
private static Map<String, MappedStatement> dynamicMappedStatementCache = new ConcurrentHashMap<>();
public FlexConfiguration(Environment environment) {
super(environment);
@ -150,7 +150,7 @@ public class FlexConfiguration extends Configuration {
//动态 resultsMap方法名称为selectListByQuery
Class<?> asType = MappedStatementTypes.getCurrentType();
if (asType != null) {
return MapUtil.computeIfAbsent(dynamicMappedStatementCache, asType,
return MapUtil.computeIfAbsent(dynamicMappedStatementCache, id + ":" + asType.getName(),
aClass -> replaceResultMap(ms, TableInfoFactory.ofEntityClass(asType))
);
}