使用以下这种方式分页并排序
Pager pager = dao.createPager(pageNumber, pageSize);
Condition c = Cnd.where("age",">",30).and("name", "LIKE", "%K%").desc("age");
List list = dao.query(Pet.class, c, pager);
pager.setRecordCount(dao.count(Pet.class,c));
return new QueryResult(list, pager);
如果排序字段数据都一样的时候,分页记录会有重复的数据显示在每页。
这个BUG希望在下个版本中修正一下。
每页10条,后台生成如下的sql
第一页
select * from(select row_number()over(order by tc)__rn__,* from(select top 10 0 tc, * FROM Pet WHERE 1='1' ORDER BY age DESC )t)tt where rn > 0 order by rn
第二页
select * from(select row_number()over(order by tc)__rn__,* from(select top 20 0 tc, * FROM Pet WHERE 1='1' ORDER BY age DESC )t)tt where rn > 10 order by rn
第三页
select * from(select row_number()over(order by tc)__rn__,* from(select top 30 0 tc, * FROM Pet WHERE 1='1' ORDER BY age DESC )t)tt where rn > 20 order by rn
18 回复
每页10条,总条数30
select top 10 * from(select row_number()over(order by tc)__rn__,* from(select top 30 0 tc, * FROM Pet WHERE 1='1' ORDER BY age DESC )t)tt where rn > 0 order by rn
严重怀疑是 sqlserver
来自美丽的 NutzCN
添加回复
请先登陆