Class PanacheQueryImpl<Entity>
- java.lang.Object
-
- io.quarkus.hibernate.reactive.panache.runtime.PanacheQueryImpl<Entity>
-
- All Implemented Interfaces:
PanacheQuery<Entity>
- Direct Known Subclasses:
CustomCountPanacheQuery
public class PanacheQueryImpl<Entity> extends Object implements PanacheQuery<Entity>
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPanacheQueryImpl(CommonPanacheQueryImpl<Entity> delegate)(package private)PanacheQueryImpl(io.smallrye.mutiny.Uni<org.hibernate.reactive.mutiny.Mutiny.Session> em, String query, String orderBy, Object paramsArrayOrMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description io.smallrye.mutiny.Uni<Long>count()Reads and caches the total number of entities this query operates on.<T extends Entity>
PanacheQuery<T>filter(String filterName)Enables a Hibernate filter during fetching of results for this query.<T extends Entity>
PanacheQuery<T>filter(String filterName, io.quarkus.panache.common.Parameters parameters)Enables a Hibernate filter during fetching of results for this query.<T extends Entity>
PanacheQuery<T>filter(String filterName, Map<String,Object> parameters)Enables a Hibernate filter during fetching of results for this query.<T extends Entity>
PanacheQuery<T>firstPage()Sets the current page to the first page<T extends Entity>
io.smallrye.mutiny.Uni<T>firstResult()Returns the first result of the current page index.io.smallrye.mutiny.Uni<Boolean>hasNextPage()Returns true if there is another page to read after the current one.booleanhasPreviousPage()Returns true if there is a page to read before the current one.<T extends Entity>
io.smallrye.mutiny.Uni<PanacheQuery<T>>lastPage()Sets the current page to the last page.<T extends Entity>
io.smallrye.mutiny.Uni<List<T>>list()Returns the current page of results as aList.<T extends Entity>
PanacheQuery<T>nextPage()Sets the current page to the next pageio.quarkus.panache.common.Pagepage()Returns the current page.<T extends Entity>
PanacheQuery<T>page(int pageIndex, int pageSize)Sets the current page.<T extends Entity>
PanacheQuery<T>page(io.quarkus.panache.common.Page page)Sets the current page.io.smallrye.mutiny.Uni<Integer>pageCount()Returns the total number of pages to be read using the current page size.<T extends Entity>
PanacheQuery<T>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>
PanacheQuery<T>range(int startIndex, int lastIndex)Switch the query to use a fixed range (start index - last index) instead of a page.<T extends Entity>
io.smallrye.mutiny.Uni<T>singleResult()Executes this query for the current page and return a single result.<T extends Entity>
io.smallrye.mutiny.Multi<T>stream()Returns the current page of results as aStream.<T extends Entity>
PanacheQuery<T>withHint(String hintName, Object value)Set a query property or hint on the underlying JPA Query.<T extends Entity>
PanacheQuery<T>withLock(javax.persistence.LockModeType lockModeType)Define the locking strategy used for this query.
-
-
-
Constructor Detail
-
PanacheQueryImpl
PanacheQueryImpl(io.smallrye.mutiny.Uni<org.hibernate.reactive.mutiny.Mutiny.Session> em, String query, String orderBy, Object paramsArrayOrMap)
-
PanacheQueryImpl
protected PanacheQueryImpl(CommonPanacheQueryImpl<Entity> delegate)
-
-
Method Detail
-
project
public <T> PanacheQuery<T> project(Class<T> type)
Description copied from interface:PanacheQueryDefines a projection class: the getters, and the public fields, will be used to restrict which fields should be retrieved from the database.- Specified by:
projectin interfacePanacheQuery<Entity>- Returns:
- a new query with the same state as the previous one (params, page, range, lockMode, hints, ...).
-
page
public <T extends Entity> PanacheQuery<T> page(io.quarkus.panache.common.Page page)
Description copied from interface:PanacheQuerySets the current page.- Specified by:
pagein interfacePanacheQuery<Entity>- Parameters:
page- the new page- Returns:
- this query, modified
- See Also:
PanacheQuery.page(int, int),PanacheQuery.page()
-
page
public <T extends Entity> PanacheQuery<T> page(int pageIndex, int pageSize)
Description copied from interface:PanacheQuerySets the current page.- Specified by:
pagein interfacePanacheQuery<Entity>- Parameters:
pageIndex- the page indexpageSize- the page size- Returns:
- this query, modified
- See Also:
PanacheQuery.page(Page),PanacheQuery.page()
-
nextPage
public <T extends Entity> PanacheQuery<T> nextPage()
Description copied from interface:PanacheQuerySets the current page to the next page- Specified by:
nextPagein interfacePanacheQuery<Entity>- Returns:
- this query, modified
- See Also:
PanacheQuery.previousPage()
-
previousPage
public <T extends Entity> PanacheQuery<T> previousPage()
Description copied from interface:PanacheQuerySets the current page to the previous page (or the first page if there is no previous page)- Specified by:
previousPagein interfacePanacheQuery<Entity>- Returns:
- this query, modified
- See Also:
PanacheQuery.nextPage()
-
firstPage
public <T extends Entity> PanacheQuery<T> firstPage()
Description copied from interface:PanacheQuerySets the current page to the first page- Specified by:
firstPagein interfacePanacheQuery<Entity>- Returns:
- this query, modified
- See Also:
PanacheQuery.lastPage()
-
lastPage
public <T extends Entity> io.smallrye.mutiny.Uni<PanacheQuery<T>> lastPage()
Description copied from interface:PanacheQuerySets the current page to the last page. This will cause reading of the entity count.- Specified by:
lastPagein interfacePanacheQuery<Entity>- Returns:
- this query, modified
- See Also:
PanacheQuery.firstPage(),PanacheQuery.count()
-
hasNextPage
public io.smallrye.mutiny.Uni<Boolean> hasNextPage()
Description copied from interface:PanacheQueryReturns true if there is another page to read after the current one. This will cause reading of the entity count.- Specified by:
hasNextPagein interfacePanacheQuery<Entity>- Returns:
- true if there is another page to read
- See Also:
PanacheQuery.hasPreviousPage(),PanacheQuery.count()
-
hasPreviousPage
public boolean hasPreviousPage()
Description copied from interface:PanacheQueryReturns true if there is a page to read before the current one.- Specified by:
hasPreviousPagein interfacePanacheQuery<Entity>- Returns:
- true if there is a previous page to read
- See Also:
PanacheQuery.hasNextPage()
-
pageCount
public io.smallrye.mutiny.Uni<Integer> pageCount()
Description copied from interface:PanacheQueryReturns the total number of pages to be read using the current page size. This will cause reading of the entity count.- Specified by:
pageCountin interfacePanacheQuery<Entity>- Returns:
- the total number of pages to be read using the current page size.
-
page
public io.quarkus.panache.common.Page page()
Description copied from interface:PanacheQueryReturns the current page.- Specified by:
pagein interfacePanacheQuery<Entity>- Returns:
- the current page
- See Also:
PanacheQuery.page(Page),PanacheQuery.page(int,int)
-
range
public <T extends Entity> PanacheQuery<T> range(int startIndex, int lastIndex)
Description copied from interface:PanacheQuerySwitch the query to use a fixed range (start index - last index) instead of a page. As the range is fixed, subsequent pagination of the query is not possible.- Specified by:
rangein interfacePanacheQuery<Entity>- Parameters:
startIndex- the index of the first element, starting at 0lastIndex- the index of the last element- Returns:
- this query, modified
-
withLock
public <T extends Entity> PanacheQuery<T> withLock(javax.persistence.LockModeType lockModeType)
Description copied from interface:PanacheQueryDefine the locking strategy used for this query.- Specified by:
withLockin interfacePanacheQuery<Entity>- Parameters:
lockModeType- the locking strategy to be used for this query.- Returns:
- this query, modified
-
withHint
public <T extends Entity> PanacheQuery<T> withHint(String hintName, Object value)
Description copied from interface:PanacheQuerySet a query property or hint on the underlying JPA Query.- Specified by:
withHintin interfacePanacheQuery<Entity>- Parameters:
hintName- name of the property or hint.value- value for the property or hint.- Returns:
- this query, modified
-
filter
public <T extends Entity> PanacheQuery<T> filter(String filterName, io.quarkus.panache.common.Parameters parameters)
Description copied from interface:PanacheQueryEnables a Hibernate filter during fetching of results for this query. Your filter must be declared with
FilterDefon your entity or package, and enabled withFilteron your entity.WARNING: setting filters can only be done on the underlying Hibernate
Sessionand 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.- Specified by:
filterin interfacePanacheQuery<Entity>- Parameters:
filterName- The name of the filter to enableparameters- The set of parameters for the filter, if the filter requires parameters- Returns:
- this query, modified
-
filter
public <T extends Entity> PanacheQuery<T> filter(String filterName, Map<String,Object> parameters)
Description copied from interface:PanacheQueryEnables a Hibernate filter during fetching of results for this query. Your filter must be declared with
FilterDefon your entity or package, and enabled withFilteron your entity.WARNING: setting filters can only be done on the underlying Hibernate
Sessionand 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.- Specified by:
filterin interfacePanacheQuery<Entity>- Parameters:
filterName- The name of the filter to enableparameters- The set of parameters for the filter, if the filter requires parameters- Returns:
- this query, modified
-
filter
public <T extends Entity> PanacheQuery<T> filter(String filterName)
Description copied from interface:PanacheQueryEnables a Hibernate filter during fetching of results for this query. Your filter must be declared with
FilterDefon your entity or package, and enabled withFilteron your entity.WARNING: setting filters can only be done on the underlying Hibernate
Sessionand 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.- Specified by:
filterin interfacePanacheQuery<Entity>- Parameters:
filterName- The name of the filter to enable- Returns:
- this query, modified
-
count
public io.smallrye.mutiny.Uni<Long> count()
Description copied from interface:PanacheQueryReads and caches the total number of entities this query operates on. This causes a database query withSELECT COUNT(*)and a query equivalent to the current query, minus ordering.- Specified by:
countin interfacePanacheQuery<Entity>- Returns:
- the total number of entities this query operates on, cached.
-
list
public <T extends Entity> io.smallrye.mutiny.Uni<List<T>> list()
Description copied from interface:PanacheQueryReturns the current page of results as aList.- Specified by:
listin interfacePanacheQuery<Entity>- Returns:
- the current page of results as a
List. - See Also:
PanacheQuery.stream(),PanacheQuery.page(Page),PanacheQuery.page()
-
stream
public <T extends Entity> io.smallrye.mutiny.Multi<T> stream()
Description copied from interface:PanacheQueryReturns the current page of results as aStream.- Specified by:
streamin interfacePanacheQuery<Entity>- Returns:
- the current page of results as a
Stream. - See Also:
PanacheQuery.list(),PanacheQuery.page(Page),PanacheQuery.page()
-
firstResult
public <T extends Entity> io.smallrye.mutiny.Uni<T> firstResult()
Description copied from interface:PanacheQueryReturns the first result of the current page index. This ignores the current page size to fetch a single result.- Specified by:
firstResultin interfacePanacheQuery<Entity>- Returns:
- the first result of the current page index, or null if there are no results.
- See Also:
PanacheQuery.singleResult()
-
singleResult
public <T extends Entity> io.smallrye.mutiny.Uni<T> singleResult()
Description copied from interface:PanacheQueryExecutes this query for the current page and return a single result.- Specified by:
singleResultin interfacePanacheQuery<Entity>- Returns:
- the single result (throws if there is not exactly one)
- See Also:
PanacheQuery.firstResult()
-
-