Package com.querydsl.mongodb
Class AbstractMongodbQuery<K,Q extends AbstractMongodbQuery<K,Q>>
java.lang.Object
com.querydsl.mongodb.AbstractMongodbQuery<K,Q>
- Type Parameters:
K- result typeQ- concrete subtype
- All Implemented Interfaces:
Fetchable<K>,FilteredClause<Q>,SimpleQuery<Q>
- Direct Known Subclasses:
MorphiaQuery
public abstract class AbstractMongodbQuery<K,Q extends AbstractMongodbQuery<K,Q>>
extends Object
implements SimpleQuery<Q>, Fetchable<K>
AbstractMongodbQuery provides a base class for general Querydsl query implementation with a
pluggable DBObject to Bean transformation- Author:
- laimw
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractMongodbQuery(com.mongodb.DBCollection collection, Function<com.mongodb.DBObject, K> transformer, MongodbSerializer serializer) Create a new MongodbQuery instance -
Method Summary
Modifier and TypeMethodDescription<T> AnyEmbeddedBuilder<Q,K> anyEmbedded(Path<? extends Collection<T>> collection, Path<T> target) Define a constraint for an embedded objectcom.mongodb.DBObjectGet the where definition as a DBObject instanceprotected com.mongodb.DBCursorprotected com.mongodb.DBCursorcreateCursor(com.mongodb.DBCollection collection, @Nullable Predicate where, Expression<?> projection, QueryModifiers modifiers, List<OrderSpecifier<?>> orderBy) protected @Nullable PredicatecreateFilter(QueryMetadata metadata) protected @Nullable PredicatecreateJoinFilter(QueryMetadata metadata) distinct()fetch()Fetch with the specific fieldslongfetchFirst(Path<?>... paths) Fetch first with the specific fieldsfetchOne()Fetch one with the specific fieldsfetchResults(Path<?>... paths) Fetch results with the specific fieldsprotected abstract com.mongodb.DBCollectiongetCollection(Class<?> type) com.mysema.commons.lang.CloseableIterator<K>iterate()com.mysema.commons.lang.CloseableIterator<K>Iterate with the specific fields<T> JoinBuilder<Q,K, T> join(CollectionPathBase<?, T, ?> ref, Path<T> target) Define a join<T> JoinBuilder<Q,K, T> Define a joinlimit(long limit) offset(long offset) orderBy(OrderSpecifier<?> o) orderBy(OrderSpecifier<?>... o) restrict(QueryModifiers modifiers) <T> Qset(ParamExpression<T> param, T value) voidsetReadPreference(com.mongodb.ReadPreference readPreference) Sets the read preference for this querytoString()
-
Constructor Details
-
AbstractMongodbQuery
public AbstractMongodbQuery(com.mongodb.DBCollection collection, Function<com.mongodb.DBObject, K> transformer, MongodbSerializer serializer) Create a new MongodbQuery instance- Parameters:
collection- collectiontransformer- result transformerserializer- serializer
-
-
Method Details
-
join
Define a join- Parameters:
ref- referencetarget- join target- Returns:
- join builder
-
join
Define a join- Parameters:
ref- referencetarget- join target- Returns:
- join builder
-
anyEmbedded
public <T> AnyEmbeddedBuilder<Q,K> anyEmbedded(Path<? extends Collection<T>> collection, Path<T> target) Define a constraint for an embedded object- Parameters:
collection- collectiontarget- target- Returns:
- builder
-
getCollection
-
createFilter
-
createJoinFilter
-
getIds
-
distinct
- Specified by:
distinctin interfaceSimpleQuery<K>
-
where
-
where
- Specified by:
wherein interfaceFilteredClause<K>
-
limit
- Specified by:
limitin interfaceSimpleQuery<K>
-
offset
- Specified by:
offsetin interfaceSimpleQuery<K>
-
restrict
- Specified by:
restrictin interfaceSimpleQuery<K>
-
orderBy
-
orderBy
- Specified by:
orderByin interfaceSimpleQuery<K>
-
set
- Specified by:
setin interfaceSimpleQuery<K>
-
iterate
Iterate with the specific fields- Parameters:
paths- fields to return- Returns:
- iterator
-
iterate
-
fetch
Fetch with the specific fields- Parameters:
paths- fields to return- Returns:
- results
-
fetch
-
createCursor
protected com.mongodb.DBCursor createCursor() -
createCursor
protected com.mongodb.DBCursor createCursor(com.mongodb.DBCollection collection, @Nullable @Nullable Predicate where, Expression<?> projection, QueryModifiers modifiers, List<OrderSpecifier<?>> orderBy) -
fetchFirst
Fetch first with the specific fields- Parameters:
paths- fields to return- Returns:
- first result
-
fetchFirst
- Specified by:
fetchFirstin interfaceFetchable<K>
-
fetchOne
Fetch one with the specific fields- Parameters:
paths- fields to return- Returns:
- first result
-
fetchOne
- Specified by:
fetchOnein interfaceFetchable<K>- Throws:
NonUniqueResultException
-
fetchResults
Fetch results with the specific fields- Parameters:
paths- fields to return- Returns:
- results
-
fetchResults
- Specified by:
fetchResultsin interfaceFetchable<K>
-
fetchCount
public long fetchCount()- Specified by:
fetchCountin interfaceFetchable<K>
-
setReadPreference
public void setReadPreference(com.mongodb.ReadPreference readPreference) Sets the read preference for this query- Parameters:
readPreference- read preference
-
asDBObject
public com.mongodb.DBObject asDBObject()Get the where definition as a DBObject instance- Returns:
-
toString
-