K
- result typeQ
- concrete subtypepublic abstract class AbstractFetchableMongodbQuery<K,Q extends AbstractFetchableMongodbQuery<K,Q>> extends AbstractMongodbQuery<Q> implements Fetchable<K>
Fetchable
Mongodb query with a pluggable Document to Bean transformation.Constructor and Description |
---|
AbstractFetchableMongodbQuery(com.mongodb.client.MongoCollection<org.bson.Document> collection,
java.util.function.Function<org.bson.Document,K> transformer,
MongodbDocumentSerializer serializer)
Create a new MongodbQuery instance
|
Modifier and Type | Method and Description |
---|---|
protected com.mongodb.client.FindIterable<org.bson.Document> |
createCursor() |
protected com.mongodb.client.FindIterable<org.bson.Document> |
createCursor(com.mongodb.client.MongoCollection<org.bson.Document> collection,
@Nullable Predicate where,
Expression<?> projection,
QueryModifiers modifiers,
java.util.List<OrderSpecifier<?>> orderBy) |
java.util.List<K> |
fetch()
Get the projection as a typed List
|
java.util.List<K> |
fetch(Path<?>... paths)
Fetch with the specific fields
|
long |
fetchCount()
Get the count of matched elements
Note: not all QueryDSL modules might optimize fetchCount using a count query.
|
K |
fetchFirst()
Get the first result of Get the projection or null if no result is found
|
K |
fetchFirst(Path<?>... paths)
Fetch first with the specific fields
|
K |
fetchOne()
Get the projection as a unique result or null if no result is found
|
K |
fetchOne(Path<?>... paths)
Fetch one with the specific fields
|
QueryResults<K> |
fetchResults()
Get the projection in
QueryResults form. |
QueryResults<K> |
fetchResults(Path<?>... paths)
Fetch results with the specific fields
|
protected abstract com.mongodb.client.MongoCollection<org.bson.Document> |
getCollection(java.lang.Class<?> type) |
protected java.util.List<java.lang.Object> |
getIds(java.lang.Class<?> targetType,
Predicate condition) |
com.mysema.commons.lang.CloseableIterator<K> |
iterate()
Get the projection as a typed closeable Iterator
|
com.mysema.commons.lang.CloseableIterator<K> |
iterate(Path<?>... paths)
Iterate with the specific fields
|
anyEmbedded, asDocument, createFilter, createJoinFilter, createProjection, createQuery, distinct, getQueryMixin, getReadPreference, getSerializer, join, join, limit, offset, orderBy, orderBy, restrict, set, setReadPreference, toString, where, where
public AbstractFetchableMongodbQuery(com.mongodb.client.MongoCollection<org.bson.Document> collection, java.util.function.Function<org.bson.Document,K> transformer, MongodbDocumentSerializer serializer)
collection
- transformer
- result transformerserializer
- serializerpublic com.mysema.commons.lang.CloseableIterator<K> iterate(Path<?>... paths)
paths
- fields to returnpublic com.mysema.commons.lang.CloseableIterator<K> iterate()
Fetchable
public java.util.List<K> fetch(Path<?>... paths)
paths
- fields to returnpublic java.util.List<K> fetch()
Fetchable
public K fetchFirst(Path<?>... paths)
paths
- fields to returnpublic K fetchFirst()
Fetchable
fetchFirst
in interface Fetchable<K>
public K fetchOne(Path<?>... paths)
paths
- fields to returnpublic K fetchOne()
Fetchable
public QueryResults<K> fetchResults(Path<?>... paths)
paths
- fields to returnpublic QueryResults<K> fetchResults()
Fetchable
QueryResults
form.
Make sure to use Fetchable.fetch()
instead if you do not rely on the QueryResults.getOffset()
or
QueryResults.getLimit()
, because it will be more performant. Also, count queries cannot be
properly generated for all dialects. For example: in JPA count queries can't be generated for queries
that have multiple group by expressions or a having clause.
Get the projection in QueryResults
form.
Use Fetchable.fetch()
instead if you do not need the total count of rows in the query result.fetchResults
in interface Fetchable<K>
Fetchable.fetch()
public long fetchCount()
Fetchable
fetch().size()
.fetchCount
in interface Fetchable<K>
protected com.mongodb.client.FindIterable<org.bson.Document> createCursor()
protected com.mongodb.client.FindIterable<org.bson.Document> createCursor(com.mongodb.client.MongoCollection<org.bson.Document> collection, @Nullable @Nullable Predicate where, Expression<?> projection, QueryModifiers modifiers, java.util.List<OrderSpecifier<?>> orderBy)
protected abstract com.mongodb.client.MongoCollection<org.bson.Document> getCollection(java.lang.Class<?> type)
protected java.util.List<java.lang.Object> getIds(java.lang.Class<?> targetType, Predicate condition)
getIds
in class AbstractMongodbQuery<Q extends AbstractFetchableMongodbQuery<K,Q>>
Copyright © 2007–2021 Querydsl. All rights reserved.