Entity
- The entity type being queriedpublic interface PanacheQuery<Entity>
List
or Stream
.
Instances of this interface cannot mutate the query itself or its parameters: only paging information can be
modified, and instances of this interface can be reused to obtain multiple pages of results.Modifier and Type | Method and Description |
---|---|
long |
count()
Reads and caches the total number of entities this query operates on.
|
<T extends Entity> |
firstPage()
Sets the current page to the first page
|
<T extends Entity> |
firstResult()
Returns the first result of the current page index.
|
<T extends Entity> |
firstResultOptional()
Returns the first result of the current page index.
|
boolean |
hasNextPage()
Returns true if there is another page to read after the current one.
|
boolean |
hasPreviousPage()
Returns true if there is a page to read before the current one.
|
<T extends Entity> |
lastPage()
Sets the current page to the last page.
|
<T extends Entity> |
list()
Returns the current page of results as a
List . |
<T extends Entity> |
nextPage()
Sets the current page to the next page
|
Page |
page()
Returns the current page.
|
<T extends Entity> |
page(int pageIndex,
int pageSize)
Sets the current page.
|
<T extends Entity> |
page(Page page)
Sets the current page.
|
int |
pageCount()
Returns the total number of pages to be read using the current page size.
|
<T extends Entity> |
previousPage()
Sets the current page to the previous page (or the first page if there is no previous page)
|
<T> PanacheQuery<T> |
project(Class<T> type)
Defines a projection class: the getters, and the public fields, will be used to restrict which fields should be
retrieved from the database.
|
<T extends Entity> |
range(int startIndex,
int lastIndex)
Switch the query to use a fixed range (start index - last index) instead of a page.
|
<T extends Entity> |
singleResult()
Executes this query for the current page and return a single result.
|
<T extends Entity> |
singleResultOptional()
Executes this query for the current page and return a single result.
|
<T extends Entity> |
stream()
Returns the current page of results as a
Stream . |
<T extends Entity> |
withCollation(com.mongodb.client.model.Collation collation)
Define the collation used for this query.
|
<T> PanacheQuery<T> project(Class<T> type)
<T extends Entity> PanacheQuery<T> page(Page page)
page
- the new pagepage(int, int)
,
page()
<T extends Entity> PanacheQuery<T> page(int pageIndex, int pageSize)
pageIndex
- the page indexpageSize
- the page sizepage(Page)
,
page()
<T extends Entity> PanacheQuery<T> nextPage()
UnsupportedOperationException
- if a page hasn't been set or if a range is already setpreviousPage()
<T extends Entity> PanacheQuery<T> previousPage()
UnsupportedOperationException
- if a page hasn't been set or if a range is already setnextPage()
<T extends Entity> PanacheQuery<T> firstPage()
UnsupportedOperationException
- if a page hasn't been set or if a range is already setlastPage()
<T extends Entity> PanacheQuery<T> lastPage()
UnsupportedOperationException
- if a page hasn't been set or if a range is already setfirstPage()
,
count()
boolean hasNextPage()
UnsupportedOperationException
- if a page hasn't been set or if a range is already sethasPreviousPage()
,
count()
boolean hasPreviousPage()
UnsupportedOperationException
- if a page hasn't been set or if a range is already sethasNextPage()
int pageCount()
UnsupportedOperationException
- if a page hasn't been set or if a range is already setPage page()
UnsupportedOperationException
- if a page hasn't been set or if a range is already setpage(Page)
,
page(int,int)
<T extends Entity> PanacheQuery<T> range(int startIndex, int lastIndex)
startIndex
- the index of the first element, starting at 0lastIndex
- the index of the last element<T extends Entity> PanacheQuery<T> withCollation(com.mongodb.client.model.Collation collation)
collation
- the collation to be used for this query.long count()
SELECT COUNT(*)
and a query equivalent to the current query, minus
ordering.<T extends Entity> List<T> list()
List
.List
.stream()
,
page(Page)
,
page()
<T extends Entity> Stream<T> stream()
Stream
.Stream
.list()
,
page(Page)
,
page()
<T extends Entity> T firstResult()
singleResult()
<T extends Entity> Optional<T> firstResultOptional()
Optional.empty()
.singleResultOptional()
<T extends Entity> T singleResult()
PanacheQueryException
- if there is not exactly one result.firstResult()
<T extends Entity> Optional<T> singleResultOptional()
Optional.empty()
.PanacheQueryException
- if there is more than one result.firstResultOptional()
Copyright © 2020 JBoss by Red Hat. All rights reserved.