升级mybatis-plus版本到 3.4.3

This commit is contained in:
admin 2021-05-21 17:52:14 +08:00
parent f230f52b44
commit 909af5302c

View File

@ -48,11 +48,6 @@ public class MPJInterceptor implements Interceptor {
*/ */
private static final Map<String, MappedStatement> MS_CACHE = new ConcurrentHashMap<>(); private static final Map<String, MappedStatement> MS_CACHE = new ConcurrentHashMap<>();
/**
* 缓存ResultMap
*/
private static final Map<Class<?>, ResultMap> RM_CACHE = new ConcurrentHashMap<>();
@Override @Override
public Object intercept(Invocation invocation) throws Throwable { public Object intercept(Invocation invocation) throws Throwable {
Object[] args = invocation.getArgs(); Object[] args = invocation.getArgs();
@ -116,23 +111,17 @@ public class MPJInterceptor implements Interceptor {
private ResultMap newResultMap(MappedStatement ms, Class<?> resultType) { private ResultMap newResultMap(MappedStatement ms, Class<?> resultType) {
TableInfo tableInfo = TableInfoHelper.getTableInfo(resultType); TableInfo tableInfo = TableInfoHelper.getTableInfo(resultType);
if (tableInfo != null && tableInfo.isAutoInitResultMap()) { if (tableInfo != null && tableInfo.isAutoInitResultMap()) {
ResultMap resultMap = RM_CACHE.get(resultType); if (tableInfo.getEntityType() != resultType) {
if (resultMap == null) { try {
if (tableInfo.getEntityType() != resultType) { Method info = TableInfoHelper.class.getDeclaredMethod("initTableInfo", Configuration.class, String.class, Class.class);
try { info.setAccessible(true);
Method info = TableInfoHelper.class.getDeclaredMethod("initTableInfo", Configuration.class, String.class, Class.class); Object invoke = info.invoke(TableInfoHelper.class, ms.getConfiguration(), ms.getId().substring(0, ms.getId().lastIndexOf(".")), resultType);
info.setAccessible(true); tableInfo = (TableInfo) invoke;
Object invoke = info.invoke(TableInfoHelper.class, ms.getConfiguration(), ms.getId().substring(0, ms.getId().lastIndexOf(".")), resultType); } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
tableInfo = (TableInfo) invoke; e.printStackTrace();
// tableInfo = TableInfoHelper.initTableInfo(ms.getConfiguration(), ms.getId().substring(0, ms.getId().lastIndexOf(".")), resultType);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
} }
resultMap = initResultMapIfNeed(tableInfo, resultType);
RM_CACHE.put(resultType, resultMap);
} }
return resultMap; return initResultMapIfNeed(tableInfo, resultType);
} }
return new ResultMap.Builder(ms.getConfiguration(), ms.getId(), resultType, EMPTY_RESULT_MAPPING).build(); return new ResultMap.Builder(ms.getConfiguration(), ms.getId(), resultType, EMPTY_RESULT_MAPPING).build();
} }