K
- result typeQ
- concrete subtypepublic 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 transformationConstructor and Description |
---|
AbstractMongodbQuery(com.mongodb.DBCollection collection,
com.google.common.base.Function<com.mongodb.DBObject,K> transformer,
MongodbSerializer serializer)
Create a new MongodbQuery instance
|
Modifier and Type | Method and Description |
---|---|
<T> AnyEmbeddedBuilder<Q,K> |
anyEmbedded(Path<? extends Collection<T>> collection,
Path<T> target)
Define a constraint for an embedded object
|
com.mongodb.DBObject |
asDBObject()
Get the where definition as a DBObject instance
|
protected com.mongodb.DBCursor |
createCursor() |
protected com.mongodb.DBCursor |
createCursor(com.mongodb.DBCollection collection,
Predicate where,
Expression<?> projection,
QueryModifiers modifiers,
List<OrderSpecifier<?>> orderBy) |
protected Predicate |
createFilter(QueryMetadata metadata) |
protected Predicate |
createJoinFilter(QueryMetadata metadata) |
Q |
distinct()
Set the Query to return distinct results
|
List<K> |
fetch()
Get the projection as a typed List
|
List<K> |
fetch(Path<?>... paths)
Fetch with the specific fields
|
long |
fetchCount()
Get the count of matched elements
|
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.DBCollection |
getCollection(Class<?> type) |
protected List<Object> |
getIds(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
|
<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 join
|
Q |
limit(long limit)
Set the limit / max results for the query results
|
Q |
offset(long offset)
Set the offset for the query results
|
Q |
orderBy(OrderSpecifier<?>... o)
Add order expressions
|
Q |
orderBy(OrderSpecifier<?> o) |
Q |
restrict(QueryModifiers modifiers)
Set both limit and offset of the query results
|
<T> Q |
set(ParamExpression<T> param,
T value)
Set the given parameter to the given value
|
void |
setReadPreference(com.mongodb.ReadPreference readPreference)
Sets the read preference for this query
|
String |
toString() |
Q |
where(Predicate... e)
Adds the given filter conditions
|
Q |
where(Predicate e) |
public AbstractMongodbQuery(com.mongodb.DBCollection collection, com.google.common.base.Function<com.mongodb.DBObject,K> transformer, MongodbSerializer serializer)
collection
- collectiontransformer
- result transformerserializer
- serializerpublic <T> JoinBuilder<Q,K,T> join(Path<T> ref, Path<T> target)
ref
- referencetarget
- join targetpublic <T> JoinBuilder<Q,K,T> join(CollectionPathBase<?,T,?> ref, Path<T> target)
ref
- referencetarget
- join targetpublic <T> AnyEmbeddedBuilder<Q,K> anyEmbedded(Path<? extends Collection<T>> collection, Path<T> target)
collection
- collectiontarget
- targetprotected abstract com.mongodb.DBCollection getCollection(Class<?> type)
@Nullable protected Predicate createFilter(QueryMetadata metadata)
@Nullable protected Predicate createJoinFilter(QueryMetadata metadata)
public Q distinct()
SimpleQuery
distinct
in interface SimpleQuery<Q extends AbstractMongodbQuery<K,Q>>
public Q where(Predicate... e)
FilteredClause
Skips null arguments
where
in interface FilteredClause<Q extends AbstractMongodbQuery<K,Q>>
e
- filter conditions to be addedpublic Q limit(long limit)
SimpleQuery
limit
in interface SimpleQuery<Q extends AbstractMongodbQuery<K,Q>>
limit
- max rowspublic Q offset(long offset)
SimpleQuery
offset
in interface SimpleQuery<Q extends AbstractMongodbQuery<K,Q>>
offset
- row offsetpublic Q restrict(QueryModifiers modifiers)
SimpleQuery
restrict
in interface SimpleQuery<Q extends AbstractMongodbQuery<K,Q>>
modifiers
- query modifierspublic Q orderBy(OrderSpecifier<?> o)
public Q orderBy(OrderSpecifier<?>... o)
SimpleQuery
orderBy
in interface SimpleQuery<Q extends AbstractMongodbQuery<K,Q>>
o
- orderpublic <T> Q set(ParamExpression<T> param, T value)
SimpleQuery
set
in interface SimpleQuery<Q extends AbstractMongodbQuery<K,Q>>
param
- paramvalue
- bindingpublic com.mysema.commons.lang.CloseableIterator<K> iterate(Path<?>... paths)
paths
- fields to returnpublic com.mysema.commons.lang.CloseableIterator<K> iterate()
Fetchable
public List<K> fetch(Path<?>... paths)
paths
- fields to returnpublic List<K> fetch()
Fetchable
protected com.mongodb.DBCursor createCursor()
protected com.mongodb.DBCursor createCursor(com.mongodb.DBCollection collection, @Nullable Predicate where, Expression<?> projection, QueryModifiers modifiers, List<OrderSpecifier<?>> orderBy)
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
formfetchResults
in interface Fetchable<K>
public long fetchCount()
Fetchable
fetchCount
in interface Fetchable<K>
public void setReadPreference(com.mongodb.ReadPreference readPreference)
readPreference
- read preferencepublic com.mongodb.DBObject asDBObject()
Copyright © 2007–2016 Querydsl. All rights reserved.