This commit is contained in:
Looly
2022-05-01 00:02:15 +08:00
parent 4613d47c84
commit 514bb54ea5
3 changed files with 4 additions and 22 deletions

View File

@@ -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);
}

View File

@@ -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);
}