.xml文件:
<select id="queryData" resultType="hashmap">
SELECT * FROM ${tableName} t WHERE is_deleted = '2'
.......
控制台:
==> Preparing: SELECT count(0) FROM user t WHERE is_deleted = '2' AND
......
service层:
Page<Map<String, Object>> dataPage = PageHelper.startPage(vo.getCurrentPage(), vo.getPageSize());
if (flag) {
......
} else {
list = userDAO.queryData(tableName, ......
......
}
dto.setCount(dataPage.getTotal());
原因分析:
userDAO.queryData虽然未使用分页查询,但是它前面的PageHelper触发了分页操作。
解决方案:
将PageHelper移动到使用分期查询的前面即可
if (flag) {
......
} else {
list = userDAO.queryData(tableName, ......
......
}
Page<Map<String, Object>> dataPage = PageHelper.startPage(vo.getCurrentPage(), vo.getPageSize());
dto.setCount(dataPage.getTotal());
最终结果:
控制台
==> Preparing: SELECT * FROM user t WHERE is_deleted = '2' ......