public class Query extends Object
Constructor and Description |
---|
Query() |
Query(CriteriaDefinition criteriaDefinition)
Creates a new
Query using the given CriteriaDefinition . |
Modifier and Type | Method and Description |
---|---|
Query |
addCriteria(CriteriaDefinition criteriaDefinition)
Adds the given
CriteriaDefinition to the current Query . |
Query |
collation(Collation collation)
Set the
Collation applying language-specific rules for string comparison. |
Query |
comment(String comment)
Add a comment to the query that is propagated to the profile log.
|
Query |
cursorBatchSize(int batchSize)
Set the number of documents to return in each response batch.
|
boolean |
equals(Object obj) |
Query |
exhaust() |
Field |
fields() |
Optional<Collation> |
getCollation()
Get the
Collation defining language-specific rules for string comparison. |
protected List<CriteriaDefinition> |
getCriteria() |
org.bson.Document |
getFieldsObject() |
String |
getHint() |
int |
getLimit()
Get the maximum number of documents to be return.
|
Meta |
getMeta() |
org.bson.Document |
getQueryObject() |
Set<Class<?>> |
getRestrictedTypes() |
long |
getSkip()
Get the number of documents to skip.
|
org.bson.Document |
getSortObject() |
int |
hashCode() |
static boolean |
isRestrictedTypeKey(String key)
Deprecated.
don't call this method as the restricted type handling will undergo some significant changes going
forward.
|
Query |
limit(int limit)
Limit the number of returned documents to
limit . |
Query |
maxScan(long maxScan)
Deprecated.
since 2.1 due to deprecation in MongoDB 4.0.
|
Query |
maxTime(Duration timeout) |
Query |
maxTime(long timeout,
TimeUnit timeUnit)
Deprecated.
since 2.1. Use
maxTime(Duration) instead. |
Query |
maxTimeMsec(long maxTimeMsec) |
Query |
noCursorTimeout() |
Query |
partialResults() |
static Query |
query(CriteriaDefinition criteriaDefinition)
Static factory method to create a
Query using the provided CriteriaDefinition . |
protected boolean |
querySettingsEquals(Query that)
Tests whether the settings of the given
Query are equal to this query. |
Query |
restrict(Class<?> type,
Class<?>... additionalTypes)
Restricts the query to only return documents instances that are exactly of the given types.
|
void |
setMeta(Meta meta) |
Query |
skip(long skip)
Set number of documents to skip before returning results.
|
Query |
slaveOk()
Allows querying of a replica slave.
|
String |
toString() |
Query |
useSnapshot()
Deprecated.
since 2.1 due to deprecation as of MongoDB 3.6
|
Query |
with(Pageable pageable)
Sets the given pagination information on the
Query instance. |
Query |
with(Sort sort)
|
Query |
withHint(String name)
Configures the query to use the given hint when being executed.
|
public Query()
public Query(CriteriaDefinition criteriaDefinition)
Query
using the given CriteriaDefinition
.criteriaDefinition
- must not be null.public static Query query(CriteriaDefinition criteriaDefinition)
Query
using the provided CriteriaDefinition
.criteriaDefinition
- must not be null.public Query addCriteria(CriteriaDefinition criteriaDefinition)
CriteriaDefinition
to the current Query
.criteriaDefinition
- must not be null.public Field fields()
public Query skip(long skip)
skip
- public Query limit(int limit)
limit
.limit
- public Query withHint(String name)
name
- must not be null or empty.public Query with(Pageable pageable)
Query
instance. Will transparently set skip
and
limit
as well as applying the Sort
instance defined with the Pageable
.pageable
- public Query restrict(Class<?> type, Class<?>... additionalTypes)
type
- may not be nulladditionalTypes
- may not be nullpublic org.bson.Document getQueryObject()
Document
.public org.bson.Document getFieldsObject()
Document
.public org.bson.Document getSortObject()
Document
.public long getSkip()
public int getLimit()
public Query maxTimeMsec(long maxTimeMsec)
maxTimeMsec
- Meta.setMaxTimeMsec(long)
@Deprecated public Query maxTime(long timeout, TimeUnit timeUnit)
maxTime(Duration)
instead.timeout
- timeUnit
- Meta.setMaxTime(long, TimeUnit)
public Query maxTime(Duration timeout)
timeout
- Meta.setMaxTime(Duration)
@Deprecated public Query maxScan(long maxScan)
maxScan
- Meta.setMaxScan(long)
public Query comment(String comment)
comment
- Meta.setComment(String)
@Deprecated public Query useSnapshot()
Meta.setSnapshot(boolean)
public Query cursorBatchSize(int batchSize)
batchSize
- The number of documents to return per batch.Meta.setCursorBatchSize(int)
public Query noCursorTimeout()
Meta.CursorOption.NO_TIMEOUT
public Query exhaust()
Meta.CursorOption.EXHAUST
public Query slaveOk()
Meta.CursorOption.SLAVE_OK
public Query partialResults()
Meta.CursorOption.PARTIAL
public Meta getMeta()
public void setMeta(Meta meta)
meta
- must not be null.public Query collation(@Nullable Collation collation)
Collation
applying language-specific rules for string comparison.collation
- can be null.public Optional<Collation> getCollation()
Collation
defining language-specific rules for string comparison.protected List<CriteriaDefinition> getCriteria()
protected boolean querySettingsEquals(Query that)
Query
are equal to this query.that
- @Deprecated public static boolean isRestrictedTypeKey(String key)
key
- Copyright © 2011–2019 Pivotal Software, Inc.. All rights reserved.