mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
4613d47c84
commit
514bb54ea5
@ -673,21 +673,10 @@ public abstract class AbstractDb<R extends AbstractDb<R>> implements ConnectionH
|
||||
* @throws DbRuntimeException SQL执行异常
|
||||
*/
|
||||
public long count(final Entity where) throws DbRuntimeException {
|
||||
return count(where, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 结果的条目数
|
||||
*
|
||||
* @param where 查询条件
|
||||
* @return 复合条件的结果数
|
||||
* @throws DbRuntimeException SQL执行异常
|
||||
*/
|
||||
public long count(final Entity where, final Page page) throws DbRuntimeException {
|
||||
Connection conn = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
return runner.count(conn, Query.of(where).setPage(page));
|
||||
return runner.count(conn, Query.of(where));
|
||||
} finally {
|
||||
this.closeConnection(conn);
|
||||
}
|
||||
|
@ -316,7 +316,9 @@ public class DialectRunner implements Serializable {
|
||||
public PageResult<Entity> page(final Connection conn, final Query query) throws DbRuntimeException {
|
||||
final Page page = query.getPage();
|
||||
final PageResultHandler pageResultHandler = new PageResultHandler(
|
||||
new PageResult<>(page.getPageNumber(), page.getPageSize(), (int) count(conn, query)),
|
||||
new PageResult<>(page.getPageNumber(), page.getPageSize(),
|
||||
// 分页查询中总数的查询要去掉分页信息
|
||||
(int) count(conn, query.clone().setPage(null))),
|
||||
this.caseInsensitive);
|
||||
return page(conn, query, pageResultHandler);
|
||||
}
|
||||
|
@ -41,15 +41,6 @@ public class DbTest {
|
||||
Assert.assertEquals(1, page1.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pageTest2() {
|
||||
final long count = Db.of().count(Entity.create("user"), Page.of(1, 3));
|
||||
Assert.assertEquals(1, count);
|
||||
|
||||
final List<Entity> page1 = Db.of().page(Entity.create("user"), Page.of(1, 3));
|
||||
Assert.assertEquals(1, page1.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pageBySqlTest() {
|
||||
final String sql = "select * from user order by name";
|
||||
|
Loading…
x
Reference in New Issue
Block a user