StringBuilder selectSql = new StringBuilder();
selectSql.append("SELECT ******** ");
selectSql.append(" ORDER BY beforeTime DESC ");
StringBuilder countSql = new StringBuilder();
countSql.append("SELECT COUNT(0) FROM (").append(selectSql).append(") AS result");
Integer count = daoTemplate.queryForInt(countSql.toString(), null);
Sql sql = Sqls.create(selectSql.toString());
Pager pager = this.daoTemplate.createPager(pageNo, pageSize);
sql.setPager(pager);
//自定义实体对象MyRowMapper
Entity<MyRowMapper> entity = new NutEntity(MyRowMapper.class);
sql.setEntity(entity);
//设置回调
sql.setCallback(Sqls.callback.records());
this.daoTemplate.execute(sql);
List<MyRowMapper> list = sql.getList(MyRowMapper.class);
return list;
|