Hint
This article is generated by AI translation.
Pagination Object
dbVisitor provides a pagination utility class PageObject that implements the Page interface. The pagination object can be used across multiple APIs —
Fluent API, Mapper Interface, Annotations, and Mapper Files all support paginated queries through it.
| Name | Description |
|---|---|
Attribute pageSize | Page size for paginated queries. Default is -1 (unlimited) |
Attribute currentPage | Current page number |
Attribute pageNumberOffset | Page number offset (e.g., set to 1 to start from page 1; otherwise the first page is 0) |
Method long getFirstRecordPosition() | Get the index position of the first record on this page |
Method long getTotalPage() | Get the total number of pages |
Method long getTotalCount() | Get the total record count |
Method long firstPage() | Move to the first page |
Method void previousPage() | Move to the previous page |
Method void nextPage() | Move to the next page |
Method void lastPage() | Move to the last page |
Method Map<String, Object> toPageInfo() | Get pagination info |
Creation
Create via static factory methods
Page page = PageObject.of(0, 20); // Page 0, 20 rows per page, page index starts at 0
Page page = PageObject.of(1, 20, 1); // Page 1, 20 rows per page, page index starts at 1
Create via constructor
PageObject page = new PageObject();
page.setPageSize(20);
toPageInfo Method
The toPageInfo method returns a Map containing pagination info:
{
"enable" : true, // Whether pagination is enabled
"pageSize" : 20, // Page size
"totalCount" : 200, // Total record count
"totalPage" : 10, // Total pages
"currentPage" : 0, // Current page number
"recordPosition" : 0// Start position of the first record
}