From e72f62df50be57e4396ad35b16b249eb8e0afb70 Mon Sep 17 00:00:00 2001 From: life <13122192336@163.com> Date: Wed, 13 Sep 2023 17:48:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=9E=9A=E4=B8=BE=E4=BD=BF?= =?UTF-8?q?=E7=94=A8flex=E9=BB=98=E8=AE=A4=E7=9A=84=E6=9E=9A=E4=B8=BE?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/mybatis/FlexConfiguration.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/mybatis/FlexConfiguration.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/mybatis/FlexConfiguration.java index 396e8040..e1b85578 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/mybatis/FlexConfiguration.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/mybatis/FlexConfiguration.java @@ -15,6 +15,7 @@ */ package com.mybatisflex.core.mybatis; +import com.mybatisflex.annotation.Table; import com.mybatisflex.core.FlexConsts; import com.mybatisflex.core.handler.CompositeEnumTypeHandler; import com.mybatisflex.core.keygen.MultiEntityKeyGenerator; @@ -28,6 +29,7 @@ import com.mybatisflex.core.row.RowMapper; import com.mybatisflex.core.table.TableInfo; import com.mybatisflex.core.table.TableInfoFactory; import com.mybatisflex.core.util.StringUtil; +import java.util.List; import org.apache.ibatis.executor.CachingExecutor; import org.apache.ibatis.executor.Executor; import org.apache.ibatis.executor.keygen.KeyGenerator; @@ -53,6 +55,7 @@ import java.util.concurrent.ConcurrentHashMap; /** * @author michael + * @author life */ public class FlexConfiguration extends Configuration { @@ -177,8 +180,17 @@ public class FlexConfiguration extends Configuration { else if (StringUtil.endsWithAny(ms.getId(), "selectOneById", "selectListByIds" , "selectListByQuery", "selectCursorByQuery")) { ms = replaceResultMap(ms, getTableInfo(ms)); + }else{ + List resultMaps1 = ms.getResultMaps(); + //根据resultMap里面的class进行 + for (ResultMap resultMap:resultMaps1) { + //获取结果的类型 + Class clazz =resultMap.getType(); + if (clazz.getDeclaredAnnotation(Table.class) !=null){//判断是否为表实体类 + ms = replaceResultMap(ms, getTableInfo(ms)); + } + } } - super.addMappedStatement(ms); }