Closed drtrang closed 6 years ago
问题描述:通用Mapper + PageHelper 无法查询出正确的结果 运行环境:SpringBoot 1.5.10 + MyBatis 3.4.5 + Mapper 3.5.2 + PageHelper 5.1.2 + Druid 1.1.7 问题复现:
@Mapper public interface BaseCodeMapper extends BaseMapper<BaseCode> { }
selectAll()
@Test public void select() { List<BaseCode> all = baseCodeMapper.selectAll(); StreamEx.of(all).map(gson::toJson).forEach(log::info); }
2018-02-06 14:16:01.762 DEBUG 16668 --- [ main] c.g.t.d.mapper.BaseCodeMapper.selectAll : ==> Preparing: SELECT id, code_type, parent_code, code, code_value , code_sort, office_address, remark, create_time, update_time FROM m_base_code 2018-02-06 14:16:01.785 DEBUG 16668 --- [ main] c.g.t.d.mapper.BaseCodeMapper.selectAll : ==> Parameters: 2018-02-06 14:16:01.827 DEBUG 16668 --- [ main] c.g.t.d.mapper.BaseCodeMapper.selectAll : <== Total: 3 2018-02-06 14:16:01.856 INFO 16668 --- [ main] com.github.trang.dynamic.test.ReadTest : {"id":1,"codeType":"drop_reason","parentCode":"0","code":"fake_work","codeValue":"虚假成交","codeSort":1,"officeAddress":0,"remark":"默认剔除原因","createTime":"2018-02-06 14:16:00","updateTime":"2018-02-06 14:16:00"} 2018-02-06 14:16:01.857 INFO 16668 --- [ main] com.github.trang.dynamic.test.ReadTest : {"id":2,"codeType":"drop_reason","parentCode":"0","code":"duplicate","codeValue":"重复网签","codeSort":7,"officeAddress":0,"remark":"默认剔除原因","createTime":"2018-02-06 14:16:00","updateTime":"2018-02-06 14:16:00"} 2018-02-06 14:16:01.858 INFO 16668 --- [ main] com.github.trang.dynamic.test.ReadTest : {"id":3,"codeType":"drop_reason","parentCode":"0","code":"other","codeValue":"其它","codeSort":11,"officeAddress":0,"remark":"默认剔除原因","createTime":"2018-02-06 14:16:00","updateTime":"2018-02-06 14:16:00"}
@Test public void page() { PageInfo<BaseCode> page = PageHelper.startPage(1, 2).doSelectPageInfo( () -> baseCodeMapper.selectAll() ); StreamEx.of(page).map(gson::toJson).forEach(log::info); StreamEx.of(page).map(PageInfo::getList).flatMap(List::stream).map(gson::toJson).forEach(log::info); }
2018-02-06 14:14:07.528 DEBUG 12464 --- [ main] c.g.t.d.mapper.BaseCodeMapper.selectAll : ==> Preparing: SELECT id, code_type, parent_code, code, code_value , code_sort, office_address, remark, create_time, update_time FROM m_base_code 2018-02-06 14:14:07.573 DEBUG 12464 --- [ main] c.g.t.d.mapper.BaseCodeMapper.selectAll : ==> Parameters: 2018-02-06 14:14:07.665 DEBUG 12464 --- [ main] c.g.t.d.mapper.BaseCodeMapper.selectAll : <== Total: 3 2018-02-06 14:14:07.723 INFO 12464 --- [ main] com.github.trang.dynamic.test.ReadTest : {"pageNum":1,"pageSize":2,"size":0,"startRow":0,"endRow":0,"total":0,"pages":0,"list":[],"prePage":0,"nextPage":0,"isFirstPage":true,"isLastPage":true,"hasPreviousPage":false,"hasNextPage":false,"navigatePages":8,"navigatepageNums":[],"navigateFirstPage":0,"navigateLastPage":0}
3.4.6 版本无此问题
@abel533 群主看下这个问题?
你可以试试最新的 4.0.0-beta 测试版,新增了多种配置方式,可以看看 wiki。
问题描述:通用Mapper + PageHelper 无法查询出正确的结果 运行环境:SpringBoot 1.5.10 + MyBatis 3.4.5 + Mapper 3.5.2 + PageHelper 5.1.2 + Druid 1.1.7 问题复现:
selectAll()
可以正常返回,共 3 条数据selectAll()
,不能正常返回数据