use of cn.hutool.db.handler.EntityListHandler in project hutool by looly.
the class SqlConnRunner method page.
/**
* 分页查询<br>
* 此方法不会关闭Connection
*
* @param conn 数据库连接对象
* @param fields 返回的字段列表,null则返回所有字段
* @param where 条件实体类(包含表名)
* @param page 分页对象
* @return 结果对象
* @throws SQLException SQL执行异常
*/
public PageResult<Entity> page(Connection conn, Collection<String> fields, Entity where, Page page) throws SQLException {
checkConn(conn);
// 查询全部
if (null == page) {
List<Entity> entityList = this.find(conn, fields, where, new EntityListHandler());
final PageResult<Entity> pageResult = new PageResult<Entity>(0, entityList.size(), entityList.size());
pageResult.addAll(entityList);
return pageResult;
}
final int count = count(conn, where);
PageResultHandler pageResultHandler = PageResultHandler.create(new PageResult<Entity>(page.getPageNumber(), page.getPageSize(), count));
return this.page(conn, fields, where, page, pageResultHandler);
}
use of cn.hutool.db.handler.EntityListHandler in project hutool by looly.
the class CRUDTest method findTest.
@Test
public void findTest() throws SQLException {
List<Entity> find = runner.find(CollUtil.newArrayList("name AS name2"), Entity.create("user"), new EntityListHandler());
Assert.assertFalse(find.isEmpty());
}
use of cn.hutool.db.handler.EntityListHandler in project hutool by looly.
the class CRUDTest method findTest.
@Test
public void findTest() throws SQLException {
List<Entity> find = db.find(CollUtil.newArrayList("name AS name2"), Entity.create("user"), new EntityListHandler());
Assert.assertFalse(find.isEmpty());
}
Aggregations