Package dev.morphia.query
Class FindOptions
- java.lang.Object
-
- dev.morphia.query.FindOptions
-
- All Implemented Interfaces:
dev.morphia.internal.SessionConfigurable<FindOptions>
public final class FindOptions extends Object implements dev.morphia.internal.SessionConfigurable<FindOptions>
The options to apply to a find operation (also commonly referred to as a query).- Since:
- 1.3
-
-
Constructor Summary
Constructors Constructor Description FindOptions()
Creates an instance with default values
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> com.mongodb.client.FindIterable<T>
apply(QueryImpl query, com.mongodb.client.FindIterable<T> iterable, Mapper mapper, Class type)
FindOptions
batchSize(int batchSize)
Sets the batch sizecom.mongodb.client.ClientSession
clientSession()
The client session to use for the insertion.FindOptions
clientSession(com.mongodb.client.ClientSession clientSession)
Set the client session to use for the insert.FindOptions
collation(com.mongodb.client.model.Collation collation)
Sets the collation to useFindOptions
comment(String comment)
Sets the comment to log with the queryFindOptions
copy()
FindOptions
cursorType(com.mongodb.CursorType cursorType)
Sets the cursor typeboolean
equals(Object o)
int
getBatchSize()
com.mongodb.client.model.Collation
getCollation()
String
getComment()
com.mongodb.CursorType
getCursorType()
org.bson.Document
getHint()
int
getLimit()
org.bson.Document
getMax()
long
getMaxAwaitTime(TimeUnit timeUnit)
long
getMaxTime(TimeUnit timeUnit)
org.bson.Document
getMin()
Projection
getProjection()
String
getQueryLogId()
com.mongodb.ReadPreference
getReadPreference()
int
getSkip()
org.bson.Document
getSort()
int
hashCode()
FindOptions
hint(String hint)
Defines the index hint valueFindOptions
hint(org.bson.Document hint)
Sets the index hintboolean
isLogQuery()
This is an experimental method.boolean
isNoCursorTimeout()
boolean
isOplogReplay()
boolean
isPartial()
boolean
isReturnKey()
boolean
isShowRecordId()
FindOptions
limit(int limit)
Sets the limitFindOptions
logQuery()
This is an experimental method.FindOptions
max(org.bson.Document max)
Sets the max index valueFindOptions
maxAwaitTime(long maxAwaitTime, TimeUnit timeUnit)
Sets the max await timeFindOptions
maxTime(long maxTime, TimeUnit timeUnit)
Sets the max timeFindOptions
min(org.bson.Document min)
Sets the min index valueFindOptions
noCursorTimeout(boolean noCursorTimeout)
Sets whether to disable cursor time outFindOptions
oplogReplay(boolean oplogReplay)
Users should not set this under normal circumstances.FindOptions
partial(boolean partial)
Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).Projection
projection()
FindOptions
readPreference(com.mongodb.ReadPreference readPreference)
Sets the read preference to applyFindOptions
returnKey(boolean returnKey)
Sets if only the key value should be returnedFindOptions
showRecordId(boolean showRecordId)
Sets if the record ID should be returnedFindOptions
skip(int skip)
Sets how many documents to skipFindOptions
sort(org.bson.Document sort)
Sets to the sort to useString
toString()
-
-
-
Method Detail
-
limit
public FindOptions limit(int limit)
Sets the limit- Parameters:
limit
- the limit- Returns:
- this
-
skip
public FindOptions skip(int skip)
Sets how many documents to skip- Parameters:
skip
- the count- Returns:
- this
-
getMaxTime
public long getMaxTime(TimeUnit timeUnit)
- Parameters:
timeUnit
- the time unit to apply- Returns:
- the max time for the operation
-
maxTime
public FindOptions maxTime(long maxTime, TimeUnit timeUnit)
Sets the max time- Parameters:
maxTime
- the maxtimeUnit
- the unit- Returns:
- this
-
getMaxAwaitTime
public long getMaxAwaitTime(TimeUnit timeUnit)
- Parameters:
timeUnit
- the time unit to apply- Returns:
- the max await time for the operation
-
maxAwaitTime
public FindOptions maxAwaitTime(long maxAwaitTime, TimeUnit timeUnit)
Sets the max await time- Parameters:
maxAwaitTime
- the maxtimeUnit
- the unit- Returns:
- this
-
batchSize
public FindOptions batchSize(int batchSize)
Sets the batch size- Parameters:
batchSize
- the size- Returns:
- this
-
projection
public Projection projection()
- Returns:
- the projection
-
sort
public FindOptions sort(org.bson.Document sort)
Sets to the sort to use- Parameters:
sort
- the sort document- Returns:
- this
-
noCursorTimeout
public FindOptions noCursorTimeout(boolean noCursorTimeout)
Sets whether to disable cursor time out- Parameters:
noCursorTimeout
- true if the time should be disabled- Returns:
- this
-
oplogReplay
public FindOptions oplogReplay(boolean oplogReplay)
Users should not set this under normal circumstances.- Parameters:
oplogReplay
- if oplog replay is enabled- Returns:
- this
-
partial
public FindOptions partial(boolean partial)
Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).- Parameters:
partial
- if partial results for sharded clusters is enabled- Returns:
- this
-
cursorType
public FindOptions cursorType(com.mongodb.CursorType cursorType)
Sets the cursor type- Parameters:
cursorType
- the type- Returns:
- this
-
collation
public FindOptions collation(com.mongodb.client.model.Collation collation)
Sets the collation to use- Parameters:
collation
- the collation- Returns:
- this
-
hint
public FindOptions hint(org.bson.Document hint)
Sets the index hint- Parameters:
hint
- the hint- Returns:
- this
-
hint
public FindOptions hint(String hint)
Defines the index hint value- Parameters:
hint
- the hint- Returns:
- this
-
max
public FindOptions max(org.bson.Document max)
Sets the max index value- Parameters:
max
- the max- Returns:
- this
-
min
public FindOptions min(org.bson.Document min)
Sets the min index value- Parameters:
min
- the min- Returns:
- this
-
returnKey
public FindOptions returnKey(boolean returnKey)
Sets if only the key value should be returned- Parameters:
returnKey
- true if only the key should be returned- Returns:
- this
-
showRecordId
public FindOptions showRecordId(boolean showRecordId)
Sets if the record ID should be returned- Parameters:
showRecordId
- true if the record id should be returned- Returns:
- this
-
readPreference
public FindOptions readPreference(com.mongodb.ReadPreference readPreference)
Sets the read preference to apply- Parameters:
readPreference
- the read preference- Returns:
- this
-
apply
public <T> com.mongodb.client.FindIterable<T> apply(QueryImpl query, com.mongodb.client.FindIterable<T> iterable, Mapper mapper, Class type)
- Type Parameters:
T
- the result type- Parameters:
query
- the query to executeiterable
- the iterable to usemapper
- the mapper to usetype
- the result type- Returns:
- the iterable instance for the query results
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getBatchSize
public int getBatchSize()
- Returns:
- the batch size
-
getLimit
public int getLimit()
- Returns:
- the limit
-
getSkip
public int getSkip()
- Returns:
- the skip count
-
getSort
public org.bson.Document getSort()
- Returns:
- the sort criteria
-
getCursorType
public com.mongodb.CursorType getCursorType()
- Returns:
- the cursor type
-
isNoCursorTimeout
public boolean isNoCursorTimeout()
- Returns:
- is the cursor timeout enabled
-
isOplogReplay
public boolean isOplogReplay()
- Returns:
- is oplog replay enabled
-
isPartial
public boolean isPartial()
- Returns:
- are partial results enabled
-
getCollation
public com.mongodb.client.model.Collation getCollation()
- Returns:
- the collation
-
getComment
public String getComment()
- Returns:
- the comment
-
getHint
public org.bson.Document getHint()
- Returns:
- the index hint
-
getMax
public org.bson.Document getMax()
- Returns:
- the max value
-
getMin
public org.bson.Document getMin()
- Returns:
- the min value
-
isReturnKey
public boolean isReturnKey()
- Returns:
- is return key only enabled
-
isShowRecordId
public boolean isShowRecordId()
- Returns:
- is showing the record id enabled
-
getReadPreference
public com.mongodb.ReadPreference getReadPreference()
- Returns:
- the read preference
-
getProjection
public Projection getProjection()
- Returns:
- the projection
-
copy
public FindOptions copy()
- Returns:
- a copy of this instance
-
logQuery
public FindOptions logQuery()
This is an experimental method. It's implementation and presence are subject to change.- Returns:
- this
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
comment
public FindOptions comment(String comment)
Sets the comment to log with the query- Parameters:
comment
- the comment- Returns:
- this
-
isLogQuery
public boolean isLogQuery()
This is an experimental method. It's implementation and presence are subject to change.- Returns:
- this
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getQueryLogId
public String getQueryLogId()
- Returns:
- the query log id used for retrieving the logged query
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
clientSession
public FindOptions clientSession(com.mongodb.client.ClientSession clientSession)
Set the client session to use for the insert.- Specified by:
clientSession
in interfacedev.morphia.internal.SessionConfigurable<FindOptions>
- Parameters:
clientSession
- the client session- Returns:
- this
- Since:
- 2.0
-
clientSession
public com.mongodb.client.ClientSession clientSession()
The client session to use for the insertion.- Specified by:
clientSession
in interfacedev.morphia.internal.SessionConfigurable<FindOptions>
- Returns:
- the client session
- Since:
- 2.0
-
-