Module spring.data.mongodb
Class SpringDataMongodbQuery<T>
java.lang.Object
com.querydsl.mongodb.document.AbstractMongodbQuery<Q>
org.springframework.data.mongodb.repository.support.SpringDataMongodbQuery<T>
- All Implemented Interfaces:
com.querydsl.core.Fetchable<T>,com.querydsl.core.FilteredClause<SpringDataMongodbQuery<T>>,com.querydsl.core.SimpleQuery<SpringDataMongodbQuery<T>>
public class SpringDataMongodbQuery<T>
extends com.querydsl.mongodb.document.AbstractMongodbQuery<Q>
implements com.querydsl.core.Fetchable<T>
Spring Data specific simple
Fetchable Query
implementation.- Author:
- Oliver Gierke, Mark Paluch, Christoph Strobl
-
Constructor Summary
ConstructorsConstructorDescriptionSpringDataMongodbQuery(MongoOperations operations, Class<? extends T> type) Creates a newSpringDataMongodbQuery.SpringDataMongodbQuery(MongoOperations operations, Class<? extends T> type, String collectionName) Creates a newSpringDataMongodbQueryto query the given collection. -
Method Summary
Modifier and TypeMethodDescriptionorg.bson.DocumentGet the where definition as a Document instanceprotected Queryprotected QuerycreateQuery(com.querydsl.core.types.Predicate filter, com.querydsl.core.types.Expression<?> projection, com.querydsl.core.QueryModifiers modifiers, List<com.querydsl.core.types.OrderSpecifier<?>> orderBy) protected org.bson.DocumentcreateSort(List<com.querydsl.core.types.OrderSpecifier<?>> orderSpecifiers) Compute the sortDocumentfrom the given list oforder specifiers.fetch()longfetchOne()Fetch aPage.com.querydsl.core.QueryResults<T>Fetch the list of ids matching a given condition.com.mysema.commons.lang.CloseableIterator<T>iterate()scroll(ScrollPosition scrollPosition) stream()toJson()Obtain the Mongo Shell json query representation.toJson(org.bson.json.JsonWriterSettings settings) Obtain the json query representation applying givensettings.toString()Returns the Mongo Shell representation of the query.Methods inherited from class com.querydsl.mongodb.document.AbstractMongodbQuery
anyEmbedded, createFilter, createJoinFilter, createProjection, createQuery, distinct, getQueryMixin, getReadPreference, getSerializer, join, join, limit, offset, orderBy, orderBy, restrict, set, setReadPreference, where, where
-
Constructor Details
-
SpringDataMongodbQuery
Creates a newSpringDataMongodbQuery.- Parameters:
operations- must not be null.type- must not be null.
-
SpringDataMongodbQuery
public SpringDataMongodbQuery(MongoOperations operations, Class<? extends T> type, String collectionName) Creates a newSpringDataMongodbQueryto query the given collection.- Parameters:
operations- must not be null.type- must not be null.collectionName- must not be null or empty.
-
-
Method Details
-
iterate
- Specified by:
iteratein interfacecom.querydsl.core.Fetchable<T>
-
scroll
-
stream
- Specified by:
streamin interfacecom.querydsl.core.Fetchable<T>
-
fetch
- Specified by:
fetchin interfacecom.querydsl.core.Fetchable<T>
-
fetchPage
Fetch aPage.- Parameters:
pageable-- Returns:
-
fetchFirst
- Specified by:
fetchFirstin interfacecom.querydsl.core.Fetchable<T>
-
fetchOne
- Specified by:
fetchOnein interfacecom.querydsl.core.Fetchable<T>
-
fetchResults
- Specified by:
fetchResultsin interfacecom.querydsl.core.Fetchable<T>
-
fetchCount
public long fetchCount()- Specified by:
fetchCountin interfacecom.querydsl.core.Fetchable<T>
-
createQuery
-
createQuery
-
getIds
Fetch the list of ids matching a given condition.- Specified by:
getIdsin classcom.querydsl.mongodb.document.AbstractMongodbQuery<SpringDataMongodbQuery<T>>- Parameters:
targetType- must not be null.condition- must not be null.- Returns:
- empty
Listif none found.
-
toString
Returns the Mongo Shell representation of the query.
The following querywhere(p.lastname.eq("Matthews")).orderBy(p.firstname.asc()).offset(1).limit(5);results infind({"lastname" : "Matthews"}).sort({"firstname" : 1}).skip(1).limit(5)Note that encoding toStringmay fail when using data types that cannot be encoded or DBRef's without an identifier.- Overrides:
toStringin classcom.querydsl.mongodb.document.AbstractMongodbQuery<Q extends org.springframework.data.mongodb.repository.support.SpringDataMongodbQuerySupport<Q>>- Returns:
- never null.
-
asDocument
public org.bson.Document asDocument()Get the where definition as a Document instance- Overrides:
asDocumentin classcom.querydsl.mongodb.document.AbstractMongodbQuery<Q extends org.springframework.data.mongodb.repository.support.SpringDataMongodbQuerySupport<Q>>- Returns:
-
toJson
Obtain the Mongo Shell json query representation.- Returns:
- never null.
-
toJson
Obtain the json query representation applying givensettings.- Parameters:
settings- must not be null.- Returns:
- never null.
-
createSort
protected org.bson.Document createSort(List<com.querydsl.core.types.OrderSpecifier<?>> orderSpecifiers) Compute the sortDocumentfrom the given list oforder specifiers.- Parameters:
orderSpecifiers- can be null.- Returns:
- an empty
Documentif predicate is null. - See Also:
-
MongodbDocumentSerializer.toSort(List)
-