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 Details

    • SpringDataMongodbQuery

      public SpringDataMongodbQuery(MongoOperations operations, Class<? extends T> type)
      Creates a new SpringDataMongodbQuery.
      Parameters:
      operations - must not be null.
      type - must not be null.
    • SpringDataMongodbQuery

      public SpringDataMongodbQuery(MongoOperations operations, Class<? extends T> type, String collectionName)
      Creates a new SpringDataMongodbQuery 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

      public com.mysema.commons.lang.CloseableIterator<T> iterate()
      Specified by:
      iterate in interface com.querydsl.core.Fetchable<T>
    • scroll

      public Window<T> scroll(ScrollPosition scrollPosition)
    • stream

      public Stream<T> stream()
      Specified by:
      stream in interface com.querydsl.core.Fetchable<T>
    • fetch

      public List<T> fetch()
      Specified by:
      fetch in interface com.querydsl.core.Fetchable<T>
    • fetchPage

      public Page<T> fetchPage(Pageable pageable)
      Fetch a Page.
      Parameters:
      pageable -
      Returns:
    • fetchFirst

      public T fetchFirst()
      Specified by:
      fetchFirst in interface com.querydsl.core.Fetchable<T>
    • fetchOne

      public T fetchOne()
      Specified by:
      fetchOne in interface com.querydsl.core.Fetchable<T>
    • fetchResults

      public com.querydsl.core.QueryResults<T> fetchResults()
      Specified by:
      fetchResults in interface com.querydsl.core.Fetchable<T>
    • fetchCount

      public long fetchCount()
      Specified by:
      fetchCount in interface com.querydsl.core.Fetchable<T>
    • createQuery

      protected Query createQuery()
    • createQuery

      protected Query createQuery(@Nullable com.querydsl.core.types.Predicate filter, @Nullable com.querydsl.core.types.Expression<?> projection, com.querydsl.core.QueryModifiers modifiers, List<com.querydsl.core.types.OrderSpecifier<?>> orderBy)
    • getIds

      protected List<Object> getIds(Class<?> targetType, com.querydsl.core.types.Predicate condition)
      Fetch the list of ids matching a given condition.
      Specified by:
      getIds in class com.querydsl.mongodb.document.AbstractMongodbQuery<SpringDataMongodbQuery<T>>
      Parameters:
      targetType - must not be null.
      condition - must not be null.
      Returns:
      empty List if none found.
    • toString

      public String toString()
      Returns the Mongo Shell representation of the query.
      The following query
      
       where(p.lastname.eq("Matthews")).orderBy(p.firstname.asc()).offset(1).limit(5);
       
      results in
      
       find({"lastname" : "Matthews"}).sort({"firstname" : 1}).skip(1).limit(5)
       
      Note that encoding to String may fail when using data types that cannot be encoded or DBRef's without an identifier.
      Overrides:
      toString in class com.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 class com.querydsl.mongodb.document.AbstractMongodbQuery<Q extends org.springframework.data.mongodb.repository.support.SpringDataMongodbQuerySupport<Q>>
      Returns:
    • toJson

      public String toJson()
      Obtain the Mongo Shell json query representation.
      Returns:
      never null.
    • toJson

      public String toJson(org.bson.json.JsonWriterSettings settings)
      Obtain the json query representation applying given settings.
      Parameters:
      settings - must not be null.
      Returns:
      never null.
    • createSort

      protected org.bson.Document createSort(List<com.querydsl.core.types.OrderSpecifier<?>> orderSpecifiers)
      Compute the sort Document from the given list of order specifiers.
      Parameters:
      orderSpecifiers - can be null.
      Returns:
      an empty Document if predicate is null.
      See Also:
      • MongodbDocumentSerializer.toSort(List)