例如:
public Pagination completeTransportations(String id, Integer pageNumber) {
String sqls = "SELECT t.id AS id,g.is_tax , t.trade_no AS trade_no,t.num AS tranWeight, g.receipt_name AS receipt_name,g.receipt_phone AS receipt_phone,g.weight AS weight, g.load_weight AS load_weight, g.weight_type AS weight_type,t.status
AS status
FROM transportation AS t JOIN goods AS g ON t.goods_id = g.id WHERE ( t.status
IN (4, 5, 6, 7) OR (t.status
=8 AND t.is_abnormal = 0 ))AND t.is_del = 0 ";
Pagination pagination = new Pagination();
if (Strings.isNotBlank(id)) {
String q = " AND t.driver_id = @id ORDER BY t.create_time DESC ";
sqls = sqls + q;
}
sql = Sqls.create(sqls);
if (Strings.isNotBlank(id)) {
sql.params().set("id", id);
}
Integer pageSize = 20;
pagination = listPage(pageNumber, pageSize, sql);
return pagination;
}
偶尔出现的sql语句就是:SELECT t.id AS id,g.is_tax , t.trade_no AS trade_no,t.num AS tranWeight, g.receipt_name AS receipt_name,g.receipt_phone AS receipt_phone,g.weight AS weight, g.load_weight AS load_weight, g.weight_type AS weight_type,t.status
AS status
FROM transportation AS t JOIN goods AS g ON t.goods_id = g.id WHERE ( t.status
IN (4, 5, 6, 7) OR (t.status
=8 AND t.is_abnormal = 0 ))AND t.is_del = 0 limit 10,10 limit 10,10
limit输出2次,甚至是3次,造成执行异常。
请问各位大神,你们有遇见过吗?
问答
使用Pagination分页时,偶尔会出现limit拼接多次,各位大神这是什么情况?
标签:
nutzwk
5 回复
public Pagination listPage(Integer pageNumber, int pageSize, Sql sql) {
pageNumber = getPageNumber(pageNumber);
pageSize = getPageSize(pageSize);
Pager pager = this.dao().createPager(pageNumber, pageSize);
pager.setRecordCount((int) Daos.queryCount(this.dao(), sql));// 记录数需手动设置
sql.setPager(pager);
sql.setCallback(Sqls.callback.records());
this.dao().execute(sql);
return new Pagination(pageNumber, pageSize, pager.getRecordCount(), sql.getList(Record.class));
}
这个是listPage里的内容
添加回复
请先登陆