Package org.hibernate.query
Class Page
- java.lang.Object
-
- org.hibernate.query.Page
-
@Incubating public class Page extends Object
Identifies a page of query results by page size and page number.This is a convenience class which allows a reference to a page of results to be passed around the system before being applied to a
Query
by callingQuery.setPage(Page)
.A parameter of a finder method or HQL query method may be declared with type
Page
.For key-based pagination, call
keyedBy(Order)
to obtain aKeyedPage
.- Since:
- 6.3
- See Also:
SelectionQuery.setPage(Page)
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Page
first()
static Page
first(int size)
Obtain an initial page with the given size.int
getFirstResult()
int
getMaxResults()
int
getNumber()
The page number, where0
is the first page.int
getSize()
The size of the page, that is, the maximum number of results on the page.boolean
isFirst()
<R> KeyedPage<R>
keyedBy(List<Order<? super R>> keyDefinition)
Obtain a key-based specification of this page.<R> KeyedPage<R>
keyedBy(Order<? super R> keyDefinition)
Obtain a key-based specification of this page.Page
next()
Obtain the next page with the same size as this page.static Page
page(int size, int number)
Obtain a page, numbered from0
, with the given size.Page
previous()
Obtain the previous page with the same size as this page.
-
-
-
Method Detail
-
getSize
public int getSize()
The size of the page, that is, the maximum number of results on the page.
-
getNumber
public int getNumber()
The page number, where0
is the first page.
-
isFirst
public boolean isFirst()
- Returns:
true
is this is the first page.
-
getMaxResults
public int getMaxResults()
- Returns:
- the page size, that is, the maximum number of results on the page.
-
getFirstResult
public int getFirstResult()
- Returns:
- the offset of this page.
-
page
public static Page page(int size, int number)
Obtain a page, numbered from0
, with the given size.- Parameters:
size
- the number of results on the initial page.number
- the number of the page, where0
is the first page.
-
first
public static Page first(int size)
Obtain an initial page with the given size.- Parameters:
size
- the number of results on the initial page.
-
next
public Page next()
Obtain the next page with the same size as this page.
-
previous
public Page previous()
Obtain the previous page with the same size as this page.- Throws:
IllegalStateException
- if this is the first page
-
first
public Page first()
-
keyedBy
public <R> KeyedPage<R> keyedBy(Order<? super R> keyDefinition)
Obtain a key-based specification of this page.
-
-