findPagedList
PagedListを使用する利点は、Query.setFirstRow(int)とQuery.setMaxRows(int)を使用して通常のクエリを使用するだけでなく、さらに機能をラップしてQuery.findFutureCount()を呼び出し、合計行数、全ページ数などを判断できる点です。
内部的にはクエリでQuery.setFirstRow(int)とQuery.setMaxRows(int)を使用しています。これはlimit offset、rownum、またはrow_number関数を用いたSQLに変換され、結果セットを制限します。
例:合計行数を含む一般的な使用法
// Find the first 100 new orders
PagedList<Order> pagedOrders
= Order.find.where()
.status.equalTo(Order.Status.NEW)
.order()
id.asc()
.setMaxRows(100)
.findPagedList();
// Optional: initiate the loading of the total
// row count in a background thread
pagedOrders.loadRowCount();
// fetch and return the list in the foreground thread
List<Order> orders = pagedOrders.getList();
// get the total row count (from the future)
int totalRowCount = pagedOrders.getTotalRowCount();