java.lang.Object
org.springframework.data.mongodb.core.query.Query
org.springframework.data.mongodb.core.query.BasicQuery
All Implemented Interfaces:
ReadConcernAware, ReadPreferenceAware

public class BasicQuery extends Query
Custom Query implementation to setup a basic query from some arbitrary JSON query string.
Author:
Thomas Risberg, Oliver Gierke, Christoph Strobl, Thomas Darimont, John Willemin, Mark Paluch
  • Constructor Details

    • BasicQuery

      public BasicQuery(@Nullable String query)
      Create a new BasicQuery given a JSON query.
      Parameters:
      query - may be null.
    • BasicQuery

      public BasicQuery(org.bson.Document queryObject)
      Create a new BasicQuery given a query Document.
      Parameters:
      queryObject - must not be null.
    • BasicQuery

      public BasicQuery(@Nullable String query, @Nullable String fields)
      Create a new BasicQuery given a JSON query and fields.
      Parameters:
      query - may be null.
      fields - may be null.
    • BasicQuery

      public BasicQuery(org.bson.Document queryObject, org.bson.Document fieldsObject)
      Create a new BasicQuery given a query Document and field specification Document.
      Parameters:
      queryObject - must not be null.
      fieldsObject - must not be null.
      Throws:
      IllegalArgumentException - when queryObject or fieldsObject is null.
  • Method Details

    • addCriteria

      public Query addCriteria(CriteriaDefinition criteria)
      Description copied from class: Query
      Adds the given CriteriaDefinition to the current Query.
      Overrides:
      addCriteria in class Query
      Parameters:
      criteria - must not be null.
      Returns:
      this.
    • getQueryObject

      public org.bson.Document getQueryObject()
      Overrides:
      getQueryObject in class Query
      Returns:
      the query Document.
    • getFieldsObject

      public org.bson.Document getFieldsObject()
      Overrides:
      getFieldsObject in class Query
      Returns:
      the field Document.
    • getSortObject

      public org.bson.Document getSortObject()
      Overrides:
      getSortObject in class Query
      Returns:
      the sort Document.
    • setSortObject

      public void setSortObject(org.bson.Document sortObject)
      Set the sort Document.
      Parameters:
      sortObject - must not be null.
      Throws:
      IllegalArgumentException - when sortObject is null.
    • isSorted

      public boolean isSorted()
      Description copied from class: Query
      Returns true if the Query has a sort parameter.
      Overrides:
      isSorted in class Query
      Returns:
      true if sorted.
      See Also:
    • setFieldsObject

      public void setFieldsObject(org.bson.Document fieldsObject)
      Set the fields (projection) Document.
      Parameters:
      fieldsObject - must not be null.
      Throws:
      IllegalArgumentException - when fieldsObject is null.
      Since:
      1.6
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Query
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Query