!341 不管xml还是flex自己的sql兼容枚举类使用flex自己的枚举类型

Merge pull request !341 from life/main
This commit is contained in:
Michael Yang 2023-09-13 10:38:41 +00:00 committed by Gitee
commit bc567538a5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -15,6 +15,7 @@
*/ */
package com.mybatisflex.core.mybatis; package com.mybatisflex.core.mybatis;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.FlexConsts; import com.mybatisflex.core.FlexConsts;
import com.mybatisflex.core.handler.CompositeEnumTypeHandler; import com.mybatisflex.core.handler.CompositeEnumTypeHandler;
import com.mybatisflex.core.keygen.MultiEntityKeyGenerator; 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.TableInfo;
import com.mybatisflex.core.table.TableInfoFactory; import com.mybatisflex.core.table.TableInfoFactory;
import com.mybatisflex.core.util.StringUtil; import com.mybatisflex.core.util.StringUtil;
import java.util.List;
import org.apache.ibatis.executor.CachingExecutor; import org.apache.ibatis.executor.CachingExecutor;
import org.apache.ibatis.executor.Executor; import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.executor.keygen.KeyGenerator; import org.apache.ibatis.executor.keygen.KeyGenerator;
@ -53,6 +55,7 @@ import java.util.concurrent.ConcurrentHashMap;
/** /**
* @author michael * @author michael
* @author life
*/ */
public class FlexConfiguration extends Configuration { public class FlexConfiguration extends Configuration {
@ -177,8 +180,17 @@ public class FlexConfiguration extends Configuration {
else if (StringUtil.endsWithAny(ms.getId(), "selectOneById", "selectListByIds" else if (StringUtil.endsWithAny(ms.getId(), "selectOneById", "selectListByIds"
, "selectListByQuery", "selectCursorByQuery")) { , "selectListByQuery", "selectCursorByQuery")) {
ms = replaceResultMap(ms, getTableInfo(ms)); ms = replaceResultMap(ms, getTableInfo(ms));
}else{
List<ResultMap> 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); super.addMappedStatement(ms);
} }