!62 BUG:selectListByQueryAs 使用实体类类型导致解析不到数据

Merge pull request !62 from 王帅/main
This commit is contained in:
Michael Yang 2023-06-13 02:05:31 +00:00 committed by Gitee
commit 5b683863b2
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 17 additions and 12 deletions

View File

@ -209,19 +209,18 @@ public class FlexConfiguration extends Configuration {
addResultMap(resultMap);
}
}
}
/*
* 这里解释一下为什么要反转这个集合
*
* MyBatis 在解析 ResultMaps 的时候是按照顺序一个一个进行解析的对于有嵌套
* ResultMap 对象也就是 nestResultMap 需要放在靠前的位置首先解析
*
* 而我们进行递归 buildResultMapList 也好fillResultMapList 也好都是
* 非嵌套 ResultMap 在集合最开始的位置所以要反转一下集合 hasNestedResultMaps
* ResultMap 对象放到集合的最前面
* 而我们进行递归 buildResultMapList 是非嵌套 ResultMap 在集合最开始的位置
* 所以要反转一下集合 hasNestedResultMaps ResultMap 对象放到集合的最
* 前面
*/
Collections.reverse(resultMapList);
}
return new MappedStatement.Builder(ms.getConfiguration(), ms.getId(), ms.getSqlSource(), ms.getSqlCommandType())
.resource(ms.getResource())

View File

@ -100,6 +100,12 @@ class UserMapperTest {
userVOS.forEach(System.err::println);
}
@Test
void testSelectListNoJoin() {
List<UserVO> userVOS = userMapper.selectListByQueryAs(QueryWrapper.create(), UserVO.class);
userVOS.forEach(System.err::println);
}
@Test
void testComplexSelectList() {
QueryWrapper queryWrapper = QueryWrapper.create()