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 java.lang.Object implements SimpleQuery<Q>, Fetchable<K>
AbstractMongodbQueryprovides a base class for general Querydsl query implementation with a pluggable DBObject to Bean transformation- Author:
- laimw
-
-
Constructor Summary
Constructors Constructor Description AbstractMongodbQuery(com.mongodb.DBCollection collection, java.util.function.Function<com.mongodb.DBObject,K> transformer, MongodbSerializer serializer)Create a new MongodbQuery instance
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T> AnyEmbeddedBuilder<Q,K>anyEmbedded(Path<? extends java.util.Collection<T>> collection, Path<T> target)Define a constraint for an embedded objectcom.mongodb.DBObjectasDBObject()Get the where definition as a DBObject instanceprotected com.mongodb.DBCursorcreateCursor()protected com.mongodb.DBCursorcreateCursor(com.mongodb.DBCollection collection, @Nullable Predicate where, Expression<?> projection, QueryModifiers modifiers, java.util.List<OrderSpecifier<?>> orderBy)protected @Nullable PredicatecreateFilter(QueryMetadata metadata)protected @Nullable PredicatecreateJoinFilter(QueryMetadata metadata)Qdistinct()java.util.List<K>fetch()java.util.List<K>fetch(Path<?>... paths)Fetch with the specific fieldslongfetchCount()KfetchFirst()KfetchFirst(Path<?>... paths)Fetch first with the specific fieldsKfetchOne()KfetchOne(Path<?>... paths)Fetch one with the specific fieldsQueryResults<K>fetchResults()QueryResults<K>fetchResults(Path<?>... paths)Fetch results with the specific fieldsprotected abstract com.mongodb.DBCollectiongetCollection(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()com.mysema.commons.lang.CloseableIterator<K>iterate(Path<?>... paths)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>join(Path<T> ref, Path<T> target)Define a joinQlimit(long limit)Qoffset(long offset)QorderBy(OrderSpecifier<?> o)QorderBy(OrderSpecifier<?>... o)Qrestrict(QueryModifiers modifiers)<T> Qset(ParamExpression<T> param, T value)voidsetReadPreference(com.mongodb.ReadPreference readPreference)Sets the read preference for this queryjava.lang.StringtoString()Qwhere(Predicate e)Qwhere(Predicate... e)
-
-
-
Constructor Detail
-
AbstractMongodbQuery
public AbstractMongodbQuery(com.mongodb.DBCollection collection, java.util.function.Function<com.mongodb.DBObject,K> transformer, MongodbSerializer serializer)Create a new MongodbQuery instance- Parameters:
collection- collectiontransformer- result transformerserializer- serializer
-
-
Method Detail
-
join
public <T> JoinBuilder<Q,K,T> join(Path<T> ref, Path<T> target)
Define a join- Parameters:
ref- referencetarget- join target- Returns:
- join builder
-
join
public <T> JoinBuilder<Q,K,T> join(CollectionPathBase<?,T,?> ref, Path<T> target)
Define a join- Parameters:
ref- referencetarget- join target- Returns:
- join builder
-
anyEmbedded
public <T> AnyEmbeddedBuilder<Q,K> anyEmbedded(Path<? extends java.util.Collection<T>> collection, Path<T> target)
Define a constraint for an embedded object- Parameters:
collection- collectiontarget- target- Returns:
- builder
-
getCollection
protected abstract com.mongodb.DBCollection getCollection(java.lang.Class<?> type)
-
createFilter
@Nullable protected @Nullable Predicate createFilter(QueryMetadata metadata)
-
createJoinFilter
@Nullable protected @Nullable Predicate createJoinFilter(QueryMetadata metadata)
-
getIds
protected java.util.List<java.lang.Object> getIds(java.lang.Class<?> targetType, Predicate condition)
-
distinct
public Q distinct()
- Specified by:
distinctin interfaceSimpleQuery<K>
-
where
public Q where(Predicate... e)
- Specified by:
wherein interfaceFilteredClause<K>
-
limit
public Q limit(long limit)
- Specified by:
limitin interfaceSimpleQuery<K>
-
offset
public Q offset(long offset)
- Specified by:
offsetin interfaceSimpleQuery<K>
-
restrict
public Q restrict(QueryModifiers modifiers)
- Specified by:
restrictin interfaceSimpleQuery<K>
-
orderBy
public Q orderBy(OrderSpecifier<?> o)
-
orderBy
public Q orderBy(OrderSpecifier<?>... o)
- Specified by:
orderByin interfaceSimpleQuery<K>
-
set
public <T> Q set(ParamExpression<T> param, T value)
- Specified by:
setin interfaceSimpleQuery<K>
-
iterate
public com.mysema.commons.lang.CloseableIterator<K> iterate(Path<?>... paths)
Iterate with the specific fields- Parameters:
paths- fields to return- Returns:
- iterator
-
iterate
public com.mysema.commons.lang.CloseableIterator<K> iterate()
-
fetch
public java.util.List<K> fetch(Path<?>... paths)
Fetch with the specific fields- Parameters:
paths- fields to return- Returns:
- results
-
createCursor
protected com.mongodb.DBCursor createCursor()
-
createCursor
protected com.mongodb.DBCursor createCursor(com.mongodb.DBCollection collection, @Nullable @Nullable Predicate where, Expression<?> projection, QueryModifiers modifiers, java.util.List<OrderSpecifier<?>> orderBy)
-
fetchFirst
public K fetchFirst(Path<?>... paths)
Fetch first with the specific fields- Parameters:
paths- fields to return- Returns:
- first result
-
fetchFirst
public K fetchFirst()
- Specified by:
fetchFirstin interfaceFetchable<K>
-
fetchOne
public K fetchOne(Path<?>... paths)
Fetch one with the specific fields- Parameters:
paths- fields to return- Returns:
- first result
-
fetchOne
public K fetchOne() throws NonUniqueResultException
- Specified by:
fetchOnein interfaceFetchable<K>- Throws:
NonUniqueResultException
-
fetchResults
public QueryResults<K> fetchResults(Path<?>... paths)
Fetch results with the specific fields- Parameters:
paths- fields to return- Returns:
- results
-
fetchResults
public QueryResults<K> 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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-