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
ConstructorDescriptionSpringDataMongodbQuery
(MongoOperations operations, Class<? extends T> type) Creates a newSpringDataMongodbQuery
.SpringDataMongodbQuery
(MongoOperations operations, Class<? extends T> type, String collectionName) Creates a newSpringDataMongodbQuery
to query the given collection. -
Method Summary
Modifier and TypeMethodDescriptionorg.bson.Document
Get the where definition as a Document instanceprotected Query
protected Query
createQuery
(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.Document
createSort
(List<com.querydsl.core.types.OrderSpecifier<?>> orderSpecifiers) Compute the sortDocument
from the given list oforder specifiers
.fetch()
long
fetchOne()
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 newSpringDataMongodbQuery
to 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:
iterate
in interfacecom.querydsl.core.Fetchable<T>
-
scroll
-
stream
- Specified by:
stream
in interfacecom.querydsl.core.Fetchable<T>
-
fetch
- Specified by:
fetch
in interfacecom.querydsl.core.Fetchable<T>
-
fetchPage
Fetch aPage
.- Parameters:
pageable
-- Returns:
-
fetchFirst
- Specified by:
fetchFirst
in interfacecom.querydsl.core.Fetchable<T>
-
fetchOne
- Specified by:
fetchOne
in interfacecom.querydsl.core.Fetchable<T>
-
fetchResults
- Specified by:
fetchResults
in interfacecom.querydsl.core.Fetchable<T>
-
fetchCount
public long fetchCount()- Specified by:
fetchCount
in interfacecom.querydsl.core.Fetchable<T>
-
createQuery
-
createQuery
-
getIds
Fetch the list of ids matching a given condition.- Specified by:
getIds
in classcom.querydsl.mongodb.document.AbstractMongodbQuery<SpringDataMongodbQuery<T>>
- Parameters:
targetType
- must not be null.condition
- must not be null.- Returns:
- empty
List
if 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 toString
may fail when using data types that cannot be encoded or DBRef's without an identifier.- Overrides:
toString
in 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:
asDocument
in 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 sortDocument
from the given list oforder specifiers
.- Parameters:
orderSpecifiers
- can be null.- Returns:
- an empty
Document
if predicate is null. - See Also:
-
MongodbDocumentSerializer.toSort(List)
-