Class BasicQuery
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 newBasicQuery
given a JSONquery
.BasicQuery
(String query, String fields) BasicQuery
(org.bson.Document queryObject) Create a newBasicQuery
given 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 givenCriteriaDefinition
to the currentQuery
.boolean
org.bson.Document
org.bson.Document
org.bson.Document
int
hashCode()
boolean
isSorted()
Returns true if theQuery
has a sort parameter.void
setFieldsObject
(org.bson.Document fieldsObject) Set the fields (projection)Document
.void
setSortObject
(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 newBasicQuery
given a JSONquery
.- Parameters:
query
- may be null.
-
BasicQuery
public BasicQuery(org.bson.Document queryObject) Create a newBasicQuery
given 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
- whenqueryObject
orfieldsObject
is null.
-
BasicQuery
- Parameters:
query
- the query to copy.- Since:
- 4.4
-
-
Method Details
-
addCriteria
Description copied from class:Query
Adds the givenCriteriaDefinition
to the currentQuery
.- Overrides:
addCriteria
in classQuery
- Parameters:
criteria
- must not be null.- Returns:
- this.
-
getQueryObject
public org.bson.Document getQueryObject()- Overrides:
getQueryObject
in classQuery
- Returns:
- the query
Document
.
-
getFieldsObject
public org.bson.Document getFieldsObject()- Overrides:
getFieldsObject
in classQuery
- Returns:
- the field
Document
.
-
getSortObject
public org.bson.Document getSortObject()- Overrides:
getSortObject
in classQuery
- Returns:
- the sort
Document
.
-
setSortObject
public void setSortObject(org.bson.Document sortObject) Set the sortDocument
.- Parameters:
sortObject
- must not be null.- Throws:
IllegalArgumentException
- whensortObject
is null.
-
isSorted
public boolean isSorted()Description copied from class:Query
Returns true if theQuery
has a sort parameter. -
setFieldsObject
public void setFieldsObject(org.bson.Document fieldsObject) Set the fields (projection)Document
.- Parameters:
fieldsObject
- must not be null.- Throws:
IllegalArgumentException
- whenfieldsObject
is null.- Since:
- 1.6
-
equals
-
hashCode
public int hashCode()
-