public class PanacheQueryImpl<Entity> extends Object implements PanacheQuery<Entity>
| Modifier | Constructor and Description |
|---|---|
protected |
PanacheQueryImpl(CommonPanacheQueryImpl<Entity> delegate) |
(package private) |
PanacheQueryImpl(javax.persistence.EntityManager em,
String query,
String orderBy,
Object paramsArrayOrMap) |
| Modifier and Type | Method and Description |
|---|---|
long |
count()
Reads and caches the total number of entities this query operates on.
|
<T extends Entity> |
filter(String filterName)
Enables a Hibernate filter during fetching of results for this query.
|
<T extends Entity> |
filter(String filterName,
Map<String,Object> parameters)
Enables a Hibernate filter during fetching of results for this query.
|
<T extends Entity> |
filter(String filterName,
Parameters parameters)
Enables a Hibernate filter during fetching of results for this query.
|
<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> |
withHint(String hintName,
Object value)
Set a query property or hint on the underlying JPA Query.
|
<T extends Entity> |
withLock(javax.persistence.LockModeType lockModeType)
Define the locking strategy used for this query.
|
PanacheQueryImpl(javax.persistence.EntityManager em,
String query,
String orderBy,
Object paramsArrayOrMap)
protected PanacheQueryImpl(CommonPanacheQueryImpl<Entity> delegate)
public <T> PanacheQuery<T> project(Class<T> type)
PanacheQueryproject in interface PanacheQuery<Entity>public <T extends Entity> PanacheQuery<T> page(Page page)
PanacheQuerypage in interface PanacheQuery<Entity>page - the new pagePanacheQuery.page(int, int),
PanacheQuery.page()public <T extends Entity> PanacheQuery<T> page(int pageIndex, int pageSize)
PanacheQuerypage in interface PanacheQuery<Entity>pageIndex - the page indexpageSize - the page sizePanacheQuery.page(Page),
PanacheQuery.page()public <T extends Entity> PanacheQuery<T> nextPage()
PanacheQuerynextPage in interface PanacheQuery<Entity>PanacheQuery.previousPage()public <T extends Entity> PanacheQuery<T> previousPage()
PanacheQuerypreviousPage in interface PanacheQuery<Entity>PanacheQuery.nextPage()public <T extends Entity> PanacheQuery<T> firstPage()
PanacheQueryfirstPage in interface PanacheQuery<Entity>PanacheQuery.lastPage()public <T extends Entity> PanacheQuery<T> lastPage()
PanacheQuerylastPage in interface PanacheQuery<Entity>PanacheQuery.firstPage(),
PanacheQuery.count()public boolean hasNextPage()
PanacheQueryhasNextPage in interface PanacheQuery<Entity>PanacheQuery.hasPreviousPage(),
PanacheQuery.count()public boolean hasPreviousPage()
PanacheQueryhasPreviousPage in interface PanacheQuery<Entity>PanacheQuery.hasNextPage()public int pageCount()
PanacheQuerypageCount in interface PanacheQuery<Entity>public Page page()
PanacheQuerypage in interface PanacheQuery<Entity>PanacheQuery.page(Page),
PanacheQuery.page(int,int)public <T extends Entity> PanacheQuery<T> range(int startIndex, int lastIndex)
PanacheQueryrange in interface PanacheQuery<Entity>startIndex - the index of the first element, starting at 0lastIndex - the index of the last elementpublic <T extends Entity> PanacheQuery<T> withLock(javax.persistence.LockModeType lockModeType)
PanacheQuerywithLock in interface PanacheQuery<Entity>lockModeType - the locking strategy to be used for this query.public <T extends Entity> PanacheQuery<T> withHint(String hintName, Object value)
PanacheQuerywithHint in interface PanacheQuery<Entity>hintName - name of the property or hint.value - value for the property or hint.public <T extends Entity> PanacheQuery<T> filter(String filterName, Parameters parameters)
PanacheQuery
Enables a Hibernate filter during fetching of results for this query. Your filter must be declared
with FilterDef on your entity or package, and enabled with Filter on your entity.
WARNING: setting filters can only be done on the underlying Hibernate Session and so this
will modify the session's filters for the duration of obtaining the results (not while building
the query). Enabled filters will be removed from the session afterwards, but no effort is made to
preserve filters enabled on the session outside of this API.
filter in interface PanacheQuery<Entity>filterName - The name of the filter to enableparameters - The set of parameters for the filter, if the filter requires parameterspublic <T extends Entity> PanacheQuery<T> filter(String filterName, Map<String,Object> parameters)
PanacheQuery
Enables a Hibernate filter during fetching of results for this query. Your filter must be declared
with FilterDef on your entity or package, and enabled with Filter on your entity.
WARNING: setting filters can only be done on the underlying Hibernate Session and so this
will modify the session's filters for the duration of obtaining the results (not while building
the query). Enabled filters will be removed from the session afterwards, but no effort is made to
preserve filters enabled on the session outside of this API.
filter in interface PanacheQuery<Entity>filterName - The name of the filter to enableparameters - The set of parameters for the filter, if the filter requires parameterspublic <T extends Entity> PanacheQuery<T> filter(String filterName)
PanacheQuery
Enables a Hibernate filter during fetching of results for this query. Your filter must be declared
with FilterDef on your entity or package, and enabled with Filter on your entity.
WARNING: setting filters can only be done on the underlying Hibernate Session and so this
will modify the session's filters for the duration of obtaining the results (not while building
the query). Enabled filters will be removed from the session afterwards, but no effort is made to
preserve filters enabled on the session outside of this API.
filter in interface PanacheQuery<Entity>filterName - The name of the filter to enablepublic long count()
PanacheQuerySELECT COUNT(*) and a query equivalent to the current query, minus
ordering.count in interface PanacheQuery<Entity>public <T extends Entity> List<T> list()
PanacheQueryList.list in interface PanacheQuery<Entity>List.PanacheQuery.stream(),
PanacheQuery.page(Page),
PanacheQuery.page()public <T extends Entity> Stream<T> stream()
PanacheQueryStream.stream in interface PanacheQuery<Entity>Stream.PanacheQuery.list(),
PanacheQuery.page(Page),
PanacheQuery.page()public <T extends Entity> T firstResult()
PanacheQueryfirstResult in interface PanacheQuery<Entity>PanacheQuery.singleResult()public <T extends Entity> Optional<T> firstResultOptional()
PanacheQueryfirstResultOptional in interface PanacheQuery<Entity>Optional.empty().PanacheQuery.singleResultOptional()public <T extends Entity> T singleResult()
PanacheQuerysingleResult in interface PanacheQuery<Entity>PanacheQuery.firstResult()public <T extends Entity> Optional<T> singleResultOptional()
PanacheQuerysingleResultOptional in interface PanacheQuery<Entity>Optional.empty().PanacheQuery.firstResultOptional()Copyright © 2021 JBoss by Red Hat. All rights reserved.