Class PanacheQueryImpl<Entity>
java.lang.Object
io.quarkus.mongodb.panache.runtime.PanacheQueryImpl<Entity>
- All Implemented Interfaces:
PanacheQuery<Entity>
-
Constructor Summary
ConstructorsConstructorDescriptionPanacheQueryImpl(com.mongodb.client.MongoCollection<? extends Entity> collection, com.mongodb.client.ClientSession session, org.bson.conversions.Bson mongoQuery, org.bson.conversions.Bson sort) -
Method Summary
Modifier and TypeMethodDescriptionlongcount()Reads and caches the total number of entities this query operates on.<T extends Entity>
PanacheQuery<T>Sets the current page to the first page<T extends Entity>
TReturns the first result of the current page index.Returns the first result of the current page index.booleanReturns true if there is another page to read after the current one.booleanReturns true if there is a page to read before the current one.<T extends Entity>
PanacheQuery<T>lastPage()Sets the current page to the last page.list()Returns the current page of results as aList.<T extends Entity>
PanacheQuery<T>nextPage()Sets the current page to the next pagepage()Returns the current page.<T extends Entity>
PanacheQuery<T>page(int pageIndex, int pageSize) Sets the current page.<T extends Entity>
PanacheQuery<T>Sets the current page.intReturns the total number of pages to be read using the current page size.<T extends Entity>
PanacheQuery<T>Sets the current page to the previous page (or the first page if there is no previous page)<T> PanacheQuery<T>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>
TExecutes this query for the current page and return a single result.Executes this query for the current page and return a single result.stream()Returns the current page of results as aStream.<T extends Entity>
PanacheQuery<T>withBatchSize(int batchSize) Define the batch size for this query.<T extends Entity>
PanacheQuery<T>withCollation(com.mongodb.client.model.Collation collation) Define the collation used for this query.<T extends Entity>
PanacheQuery<T>withReadPreference(com.mongodb.ReadPreference readPreference) Define the read preference used for this query.
-
Constructor Details
-
PanacheQueryImpl
PanacheQueryImpl(com.mongodb.client.MongoCollection<? extends Entity> collection, com.mongodb.client.ClientSession session, org.bson.conversions.Bson mongoQuery, org.bson.conversions.Bson sort)
-
-
Method Details
-
project
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, ...).
-
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:
-
page
Description copied from interface:PanacheQuerySets the current page.- Specified by:
pagein interfacePanacheQuery<Entity>- Parameters:
pageIndex- the page index (0-based)pageSize- the page size- Returns:
- this query, modified
- See Also:
-
nextPage
Description copied from interface:PanacheQuerySets the current page to the next page- Specified by:
nextPagein interfacePanacheQuery<Entity>- Returns:
- this query, modified
- See Also:
-
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:
-
firstPage
Description copied from interface:PanacheQuerySets the current page to the first page- Specified by:
firstPagein interfacePanacheQuery<Entity>- Returns:
- this query, modified
- See Also:
-
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:
-
hasNextPage
public 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:
-
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:
-
pageCount
public int 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
Description copied from interface:PanacheQueryReturns the current page.- Specified by:
pagein interfacePanacheQuery<Entity>- Returns:
- the current page
- See Also:
-
range
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
-
withCollation
public <T extends Entity> PanacheQuery<T> withCollation(com.mongodb.client.model.Collation collation) Description copied from interface:PanacheQueryDefine the collation used for this query.- Specified by:
withCollationin interfacePanacheQuery<Entity>- Parameters:
collation- the collation to be used for this query.- Returns:
- this query, modified
-
withReadPreference
public <T extends Entity> PanacheQuery<T> withReadPreference(com.mongodb.ReadPreference readPreference) Description copied from interface:PanacheQueryDefine the read preference used for this query.- Specified by:
withReadPreferencein interfacePanacheQuery<Entity>- Parameters:
readPreference- the read preference to be used for this query.- Returns:
- this query, modified
-
withBatchSize
Description copied from interface:PanacheQueryDefine the batch size for this query.- Specified by:
withBatchSizein interfacePanacheQuery<Entity>- Parameters:
batchSize- the batch size to be used for this query.- Returns:
- this query, modified
-
count
public 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
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:
-
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:
-
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:
-
firstResultOptional
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:
firstResultOptionalin interfacePanacheQuery<Entity>- Returns:
- if found, an optional containing the entity, else
Optional.empty(). - See Also:
-
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
- See Also:
-
singleResultOptional
Description copied from interface:PanacheQueryExecutes this query for the current page and return a single result.- Specified by:
singleResultOptionalin interfacePanacheQuery<Entity>- Returns:
- if found, an optional containing the entity, else
Optional.empty(). - See Also:
-