java.lang.Object
org.springframework.data.mongodb.core.query.Query
org.springframework.data.mongodb.core.query.BasicQuery
- All Implemented Interfaces:
ReadConcernAware,ReadPreferenceAware
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 Summary
ConstructorsConstructorDescriptionBasicQuery(String query) Create a newBasicQuerygiven a JSONquery.BasicQuery(String query, String fields) BasicQuery(org.bson.Document queryObject) Create a newBasicQuerygiven a queryDocument.BasicQuery(org.bson.Document queryObject, org.bson.Document fieldsObject) BasicQuery(Query query) Create a BasicQuery given aQuery. -
Method Summary
Modifier and TypeMethodDescriptionaddCriteria(CriteriaDefinition criteria) Adds the givenCriteriaDefinitionto the currentQuery.booleanorg.bson.Documentorg.bson.Documentorg.bson.DocumentinthashCode()booleanisSorted()Returns true if theQueryhas a sort parameter.voidsetFieldsObject(org.bson.Document fieldsObject) Set the fields (projection)Document.voidsetSortObject(org.bson.Document sortObject) Set the sortDocument.Methods inherited from class org.springframework.data.mongodb.core.query.Query
allowDiskUse, allowSecondaryReads, collation, comment, cursorBatchSize, exhaust, fields, getCollation, getCriteria, getHint, getKeyset, getLimit, getMeta, getReadConcern, getReadPreference, getRestrictedTypes, getSkip, hasKeyset, hasReadConcern, hasReadPreference, isLimited, isRestrictedTypeKey, limit, limit, maxTime, maxTimeMsec, noCursorTimeout, of, partialResults, query, querySettingsEquals, restrict, setMeta, skip, toString, with, with, with, with, with, withHint, withHint, withReadConcern, withReadPreference
-
Constructor Details
-
BasicQuery
Create a newBasicQuerygiven a JSONquery.- Parameters:
query- may be null.
-
BasicQuery
public BasicQuery(org.bson.Document queryObject) Create a newBasicQuerygiven a queryDocument.- Parameters:
queryObject- must not be null.
-
BasicQuery
- Parameters:
query- may be null.fields- may be null.
-
BasicQuery
public BasicQuery(org.bson.Document queryObject, org.bson.Document fieldsObject) - Parameters:
queryObject- must not be null.fieldsObject- must not be null.- Throws:
IllegalArgumentException- whenqueryObjectorfieldsObjectis null.
-
BasicQuery
- Parameters:
query- the query to copy.- Since:
- 4.4
-
-
Method Details
-
addCriteria
Description copied from class:QueryAdds the givenCriteriaDefinitionto the currentQuery.- Overrides:
addCriteriain classQuery- Parameters:
criteria- must not be null.- Returns:
- this.
-
getQueryObject
public org.bson.Document getQueryObject()- Overrides:
getQueryObjectin classQuery- Returns:
- the query
Document.
-
getFieldsObject
public org.bson.Document getFieldsObject()- Overrides:
getFieldsObjectin classQuery- Returns:
- the field
Document.
-
getSortObject
public org.bson.Document getSortObject()- Overrides:
getSortObjectin classQuery- Returns:
- the sort
Document.
-
setSortObject
public void setSortObject(org.bson.Document sortObject) Set the sortDocument.- Parameters:
sortObject- must not be null.- Throws:
IllegalArgumentException- whensortObjectis null.
-
isSorted
public boolean isSorted()Description copied from class:QueryReturns true if theQueryhas a sort parameter. -
setFieldsObject
public void setFieldsObject(org.bson.Document fieldsObject) Set the fields (projection)Document.- Parameters:
fieldsObject- must not be null.- Throws:
IllegalArgumentException- whenfieldsObjectis null.- Since:
- 1.6
-
equals
-
hashCode
public int hashCode()
-