Class AbstractMongodbQuery<K,Q extends AbstractMongodbQuery<K,Q>>

java.lang.Object
com.querydsl.mongodb.AbstractMongodbQuery<K,Q>
Type Parameters:
K - result type
Q - 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 Details

    • AbstractMongodbQuery

      public AbstractMongodbQuery(com.mongodb.DBCollection collection, Function<com.mongodb.DBObject,K> transformer, MongodbSerializer serializer)
      Create a new MongodbQuery instance
      Parameters:
      collection - collection
      transformer - result transformer
      serializer - serializer
  • Method Details

    • join

      public <T> JoinBuilder<Q,K,T> join(Path<T> ref, Path<T> target)
      Define a join
      Parameters:
      ref - reference
      target - join target
      Returns:
      join builder
    • join

      public <T> JoinBuilder<Q,K,T> join(CollectionPathBase<?,T,?> ref, Path<T> target)
      Define a join
      Parameters:
      ref - reference
      target - 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 - collection
      target - target
      Returns:
      builder
    • getCollection

      protected abstract com.mongodb.DBCollection getCollection(Class<?> type)
    • createFilter

      @Nullable protected @Nullable Predicate createFilter(QueryMetadata metadata)
    • createJoinFilter

      @Nullable protected @Nullable Predicate createJoinFilter(QueryMetadata metadata)
    • getIds

      protected List<Object> getIds(Class<?> targetType, Predicate condition)
    • distinct

      public Q distinct()
      Specified by:
      distinct in interface SimpleQuery<K>
    • where

      public Q where(Predicate e)
    • where

      public Q where(Predicate... e)
      Specified by:
      where in interface FilteredClause<K>
    • limit

      public Q limit(long limit)
      Specified by:
      limit in interface SimpleQuery<K>
    • offset

      public Q offset(long offset)
      Specified by:
      offset in interface SimpleQuery<K>
    • restrict

      public Q restrict(QueryModifiers modifiers)
      Specified by:
      restrict in interface SimpleQuery<K>
    • orderBy

      public Q orderBy(OrderSpecifier<?> o)
    • orderBy

      public Q orderBy(OrderSpecifier<?>... o)
      Specified by:
      orderBy in interface SimpleQuery<K>
    • set

      public <T> Q set(ParamExpression<T> param, T value)
      Specified by:
      set in interface SimpleQuery<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()
      Specified by:
      iterate in interface Fetchable<K>
    • fetch

      public List<K> fetch(Path<?>... paths)
      Fetch with the specific fields
      Parameters:
      paths - fields to return
      Returns:
      results
    • fetch

      public List<K> fetch()
      Specified by:
      fetch in interface Fetchable<K>
    • 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

      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:
      fetchFirst in interface Fetchable<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:
      fetchOne in interface Fetchable<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:
      fetchResults in interface Fetchable<K>
    • fetchCount

      public long fetchCount()
      Specified by:
      fetchCount in interface Fetchable<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 String toString()
      Overrides:
      toString in class Object