From 909af5302c452b64a721a9dd84e259c98cd11473 Mon Sep 17 00:00:00 2001 From: admin <570810310@qq.com> Date: Fri, 21 May 2021 17:52:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7mybatis-plus=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=88=B0=203.4.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yulichang/interceptor/MPJInterceptor.java | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/github/yulichang/interceptor/MPJInterceptor.java b/src/main/java/com/github/yulichang/interceptor/MPJInterceptor.java index 6362849..9b21152 100644 --- a/src/main/java/com/github/yulichang/interceptor/MPJInterceptor.java +++ b/src/main/java/com/github/yulichang/interceptor/MPJInterceptor.java @@ -48,11 +48,6 @@ public class MPJInterceptor implements Interceptor { */ private static final Map MS_CACHE = new ConcurrentHashMap<>(); - /** - * 缓存ResultMap - */ - private static final Map, ResultMap> RM_CACHE = new ConcurrentHashMap<>(); - @Override public Object intercept(Invocation invocation) throws Throwable { Object[] args = invocation.getArgs(); @@ -116,23 +111,17 @@ public class MPJInterceptor implements Interceptor { private ResultMap newResultMap(MappedStatement ms, Class resultType) { TableInfo tableInfo = TableInfoHelper.getTableInfo(resultType); if (tableInfo != null && tableInfo.isAutoInitResultMap()) { - ResultMap resultMap = RM_CACHE.get(resultType); - if (resultMap == null) { - if (tableInfo.getEntityType() != resultType) { - try { - Method info = TableInfoHelper.class.getDeclaredMethod("initTableInfo", Configuration.class, String.class, Class.class); - info.setAccessible(true); - Object invoke = info.invoke(TableInfoHelper.class, ms.getConfiguration(), ms.getId().substring(0, ms.getId().lastIndexOf(".")), resultType); - tableInfo = (TableInfo) invoke; -// tableInfo = TableInfoHelper.initTableInfo(ms.getConfiguration(), ms.getId().substring(0, ms.getId().lastIndexOf(".")), resultType); - } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { - e.printStackTrace(); - } + if (tableInfo.getEntityType() != resultType) { + try { + Method info = TableInfoHelper.class.getDeclaredMethod("initTableInfo", Configuration.class, String.class, Class.class); + info.setAccessible(true); + Object invoke = info.invoke(TableInfoHelper.class, ms.getConfiguration(), ms.getId().substring(0, ms.getId().lastIndexOf(".")), resultType); + tableInfo = (TableInfo) invoke; + } 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(); }