Package com.mongodb.operation
Class FindOperation<T>
- java.lang.Object
-
- com.mongodb.operation.FindOperation<T>
-
- Type Parameters:
T
- the operations result type.
- All Implemented Interfaces:
AsyncReadOperation<AsyncBatchCursor<T>>
,ReadOperation<BatchCursor<T>>
@Deprecated public class FindOperation<T> extends Object implements AsyncReadOperation<AsyncBatchCursor<T>>, ReadOperation<BatchCursor<T>>
Deprecated.An operation that queries a collection using the provided criteria.- Since:
- 3.0
-
-
Constructor Summary
Constructors Constructor Description FindOperation(MongoNamespace namespace, Decoder<T> decoder)
Deprecated.Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ReadOperation<BsonDocument>
asExplainableOperation(ExplainVerbosity explainVerbosity)
Deprecated.Gets an operation whose execution explains this operation.AsyncReadOperation<BsonDocument>
asExplainableOperationAsync(ExplainVerbosity explainVerbosity)
Deprecated.Gets an operation whose execution explains this operation.FindOperation<T>
batchSize(int batchSize)
Deprecated.Sets the number of documents to return per batch.FindOperation<T>
collation(Collation collation)
Deprecated.Sets the collation optionsFindOperation<T>
comment(String comment)
Deprecated.Sets the comment to the query.FindOperation<T>
cursorType(CursorType cursorType)
Deprecated.Sets the cursor type.BatchCursor<T>
execute(ReadBinding binding)
Deprecated.General execute which can return anything of type Tvoid
executeAsync(AsyncReadBinding binding, SingleResultCallback<AsyncBatchCursor<T>> callback)
Deprecated.General execute which can return anything of type TFindOperation<T>
filter(BsonDocument filter)
Deprecated.Sets the query filter to apply to the query.int
getBatchSize()
Deprecated.Gets the number of documents to return per batch.Collation
getCollation()
Deprecated.Returns the collation optionsString
getComment()
Deprecated.Returns the comment to send with the query.CursorType
getCursorType()
Deprecated.Get the cursor type.Decoder<T>
getDecoder()
Deprecated.Gets the decoder used to decode the result documents.BsonDocument
getFilter()
Deprecated.Gets the query filter.BsonDocument
getHint()
Deprecated.Returns the hint for which index to use.int
getLimit()
Deprecated.Gets the limit to apply.BsonDocument
getMax()
Deprecated.Returns the exclusive upper bound for a specific index.long
getMaxAwaitTime(TimeUnit timeUnit)
Deprecated.The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query.long
getMaxScan()
Deprecated.Deprecated as of MongoDB 4.0 releaselong
getMaxTime(TimeUnit timeUnit)
Deprecated.Gets the maximum execution time on the server for this operation.BsonDocument
getMin()
Deprecated.Returns the minimum inclusive lower bound for a specific index.BsonDocument
getModifiers()
Deprecated.Gets the query modifiers to apply to this operation.MongoNamespace
getNamespace()
Deprecated.Gets the namespace.BsonDocument
getProjection()
Deprecated.Gets a document describing the fields to return for all matching documents.boolean
getRetryReads()
Deprecated.Gets the value for retryable reads.int
getSkip()
Deprecated.Gets the number of documents to skip.BsonDocument
getSort()
Deprecated.Gets the sort criteria to apply to the query.FindOperation<T>
hint(BsonDocument hint)
Deprecated.Sets the hint for which index to use.boolean
isNoCursorTimeout()
Deprecated.Returns true if cursor timeout has been turned off.boolean
isOplogReplay()
Deprecated.Internal replication use only.boolean
isPartial()
Deprecated.Returns true if can get partial results from a mongos if some shards are down.boolean
isReturnKey()
Deprecated.Returns the returnKey.boolean
isShowRecordId()
Deprecated.Returns the showRecordId.boolean
isSlaveOk()
Deprecated.Returns true if set to allowed to query non-primary replica set members.boolean
isSnapshot()
Deprecated.Deprecated in MongoDB 3.6 release and removed in MongoDB 4.0 releaseFindOperation<T>
limit(int limit)
Deprecated.Sets the limit to apply.FindOperation<T>
max(BsonDocument max)
Deprecated.Sets the exclusive upper bound for a specific index.FindOperation<T>
maxAwaitTime(long maxAwaitTime, TimeUnit timeUnit)
Deprecated.Sets the maximum await execution time on the server for this operation.FindOperation<T>
maxScan(long maxScan)
Deprecated.Deprecated as of MongoDB 4.0 releaseFindOperation<T>
maxTime(long maxTime, TimeUnit timeUnit)
Deprecated.Sets the maximum execution time on the server for this operation.FindOperation<T>
min(BsonDocument min)
Deprecated.Sets the minimum inclusive lower bound for a specific index.FindOperation<T>
modifiers(BsonDocument modifiers)
Deprecated.use the individual setters insteadFindOperation<T>
noCursorTimeout(boolean noCursorTimeout)
Deprecated.Sets if the cursor timeout should be turned off.FindOperation<T>
oplogReplay(boolean oplogReplay)
Deprecated.Internal replication use only.FindOperation<T>
partial(boolean partial)
Deprecated.Sets if partial results from a mongos if some shards are down are allowedFindOperation<T>
projection(BsonDocument projection)
Deprecated.Sets a document describing the fields to return for all matching documents.FindOperation<T>
retryReads(boolean retryReads)
Deprecated.Enables retryable reads if a read fails due to a network error.FindOperation<T>
returnKey(boolean returnKey)
Deprecated.Sets the returnKey.FindOperation<T>
showRecordId(boolean showRecordId)
Deprecated.Sets the showRecordId.FindOperation<T>
skip(int skip)
Deprecated.Sets the number of documents to skip.FindOperation<T>
slaveOk(boolean slaveOk)
Deprecated.Sets if allowed to query non-primary replica set members.FindOperation<T>
snapshot(boolean snapshot)
Deprecated.Deprecated in MongoDB 3.6 release and removed in MongoDB 4.0 releaseFindOperation<T>
sort(BsonDocument sort)
Deprecated.Sets the sort criteria to apply to the query.
-
-
-
Constructor Detail
-
FindOperation
public FindOperation(MongoNamespace namespace, Decoder<T> decoder)
Deprecated.Construct a new instance.- Parameters:
namespace
- the database and collection namespace for the operation.decoder
- the decoder for the result documents.
-
-
Method Detail
-
getNamespace
public MongoNamespace getNamespace()
Deprecated.Gets the namespace.- Returns:
- the namespace
-
getDecoder
public Decoder<T> getDecoder()
Deprecated.Gets the decoder used to decode the result documents.- Returns:
- the decoder
-
getFilter
public BsonDocument getFilter()
Deprecated.Gets the query filter.- Returns:
- the query filter
- MongoDB documentation
- Filter
-
filter
public FindOperation<T> filter(BsonDocument filter)
Deprecated.Sets the query filter to apply to the query.- Parameters:
filter
- the filter, which may be null.- Returns:
- this
- MongoDB documentation
- Filter
-
getBatchSize
public int getBatchSize()
Deprecated.Gets the number of documents to return per batch. Default to 0, which indicates that the server chooses an appropriate batch size.- Returns:
- the batch size, which may be null
- MongoDB documentation
- Batch Size
-
batchSize
public FindOperation<T> batchSize(int batchSize)
Deprecated.Sets the number of documents to return per batch.- Parameters:
batchSize
- the batch size- Returns:
- this
- MongoDB documentation
- Batch Size
-
getLimit
public int getLimit()
Deprecated.Gets the limit to apply. The default is null.- Returns:
- the limit
- MongoDB documentation
- Limit
-
limit
public FindOperation<T> limit(int limit)
Deprecated.Sets the limit to apply.- Parameters:
limit
- the limit, which may be null- Returns:
- this
- MongoDB documentation
- Limit
-
getModifiers
public BsonDocument getModifiers()
Deprecated.Gets the query modifiers to apply to this operation. The default is not to apply any modifiers.- Returns:
- the query modifiers, which may be null
- MongoDB documentation
- Query Modifiers
-
modifiers
@Deprecated public FindOperation<T> modifiers(BsonDocument modifiers)
Deprecated.use the individual setters insteadSets the query modifiers to apply to this operation.- Parameters:
modifiers
- the query modifiers to apply, which may be null.- Returns:
- this
- MongoDB documentation
- Query Modifiers
-
getProjection
public BsonDocument getProjection()
Deprecated.Gets a document describing the fields to return for all matching documents.- Returns:
- the project document, which may be null
- MongoDB documentation
- Projection
-
projection
public FindOperation<T> projection(BsonDocument projection)
Deprecated.Sets a document describing the fields to return for all matching documents.- Parameters:
projection
- the project document, which may be null.- Returns:
- this
- MongoDB documentation
- Projection
-
getMaxTime
public long getMaxTime(TimeUnit timeUnit)
Deprecated.Gets the maximum execution time on the server for this operation. The default is 0, which places no limit on the execution time.- Parameters:
timeUnit
- the time unit to return the result in- Returns:
- the maximum execution time in the given time unit
-
maxTime
public FindOperation<T> maxTime(long maxTime, TimeUnit timeUnit)
Deprecated.Sets the maximum execution time on the server for this operation.- Parameters:
maxTime
- the max timetimeUnit
- the time unit, which may not be null- Returns:
- this
-
getMaxAwaitTime
public long getMaxAwaitTime(TimeUnit timeUnit)
Deprecated.The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query. This only applies to a TAILABLE_AWAIT cursor. When the cursor is not a TAILABLE_AWAIT cursor, this option is ignored. On servers >= 3.2, this option will be specified on the getMore command as "maxTimeMS". The default is no value: no "maxTimeMS" is sent to the server with the getMore command. On servers < 3.2, this option is ignored, and indicates that the driver should respect the server's default value A zero value will be ignored.- Parameters:
timeUnit
- the time unit to return the result in- Returns:
- the maximum await execution time in the given time unit
- Since:
- 3.2
- MongoDB documentation
- Max Time
-
maxAwaitTime
public FindOperation<T> maxAwaitTime(long maxAwaitTime, TimeUnit timeUnit)
Deprecated.Sets the maximum await execution time on the server for this operation.- Parameters:
maxAwaitTime
- the max await time. A zero value will be ignored, and indicates that the driver should respect the server's default valuetimeUnit
- the time unit, which may not be null- Returns:
- this
- Since:
- 3.2
- MongoDB documentation
- Max Time
-
getSkip
public int getSkip()
Deprecated.Gets the number of documents to skip. The default is 0.- Returns:
- the number of documents to skip, which may be null
- MongoDB documentation
- Skip
-
skip
public FindOperation<T> skip(int skip)
Deprecated.Sets the number of documents to skip.- Parameters:
skip
- the number of documents to skip- Returns:
- this
- MongoDB documentation
- Skip
-
getSort
public BsonDocument getSort()
Deprecated.Gets the sort criteria to apply to the query. The default is null, which means that the documents will be returned in an undefined order.- Returns:
- a document describing the sort criteria
- MongoDB documentation
- Sort
-
sort
public FindOperation<T> sort(BsonDocument sort)
Deprecated.Sets the sort criteria to apply to the query.- Parameters:
sort
- the sort criteria, which may be null.- Returns:
- this
- MongoDB documentation
- Sort
-
getCursorType
public CursorType getCursorType()
Deprecated.Get the cursor type.- Returns:
- the cursor type
-
cursorType
public FindOperation<T> cursorType(CursorType cursorType)
Deprecated.Sets the cursor type.- Parameters:
cursorType
- the cursor type- Returns:
- this
-
isSlaveOk
public boolean isSlaveOk()
Deprecated.Returns true if set to allowed to query non-primary replica set members.- Returns:
- true if set to allowed to query non-primary replica set members.
- MongoDB documentation
- OP_QUERY
-
slaveOk
public FindOperation<T> slaveOk(boolean slaveOk)
Deprecated.Sets if allowed to query non-primary replica set members.- Parameters:
slaveOk
- true if allowed to query non-primary replica set members.- Returns:
- this
- MongoDB documentation
- OP_QUERY
-
isOplogReplay
public boolean isOplogReplay()
Deprecated.Internal replication use only. Driver users should ordinarily not use this.- Returns:
- oplogReplay
- MongoDB documentation
- OP_QUERY
-
oplogReplay
public FindOperation<T> oplogReplay(boolean oplogReplay)
Deprecated.Internal replication use only. Driver users should ordinarily not use this.- Parameters:
oplogReplay
- the oplogReplay value- Returns:
- this
- MongoDB documentation
- OP_QUERY
-
isNoCursorTimeout
public boolean isNoCursorTimeout()
Deprecated.Returns true if cursor timeout has been turned off.The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use.
- Returns:
- if cursor timeout has been turned off
- MongoDB documentation
- OP_QUERY
-
noCursorTimeout
public FindOperation<T> noCursorTimeout(boolean noCursorTimeout)
Deprecated.Sets if the cursor timeout should be turned off.- Parameters:
noCursorTimeout
- true if the cursor timeout should be turned off.- Returns:
- this
- MongoDB documentation
- OP_QUERY
-
isPartial
public boolean isPartial()
Deprecated.Returns true if can get partial results from a mongos if some shards are down.- Returns:
- if can get partial results from a mongos if some shards are down
- MongoDB documentation
- OP_QUERY
-
partial
public FindOperation<T> partial(boolean partial)
Deprecated.Sets if partial results from a mongos if some shards are down are allowed- Parameters:
partial
- allow partial results from a mongos if some shards are down- Returns:
- this
- MongoDB documentation
- OP_QUERY
-
getCollation
public Collation getCollation()
Deprecated.Returns the collation options- Returns:
- the collation options
- Since:
- 3.4
- Since server release
- 3.4
-
collation
public FindOperation<T> collation(Collation collation)
Deprecated.Sets the collation optionsA null value represents the server default.
- Parameters:
collation
- the collation options to use- Returns:
- this
- Since:
- 3.4
- Since server release
- 3.4
-
getComment
public String getComment()
Deprecated.Returns the comment to send with the query. The default is not to include a comment with the query.- Returns:
- the comment
- Since:
- 3.5
-
comment
public FindOperation<T> comment(String comment)
Deprecated.Sets the comment to the query. A null value means no comment is set.- Parameters:
comment
- the comment- Returns:
- this
- Since:
- 3.5
-
getHint
public BsonDocument getHint()
Deprecated.Returns the hint for which index to use. The default is not to set a hint.- Returns:
- the hint
- Since:
- 3.5
-
hint
public FindOperation<T> hint(BsonDocument hint)
Deprecated.Sets the hint for which index to use. A null value means no hint is set.- Parameters:
hint
- the hint- Returns:
- this
- Since:
- 3.5
-
getMax
public BsonDocument getMax()
Deprecated.Returns the exclusive upper bound for a specific index. By default there is no max bound.- Returns:
- the max
- Since:
- 3.5
-
max
public FindOperation<T> max(BsonDocument max)
Deprecated.Sets the exclusive upper bound for a specific index. A null value means no max is set.- Parameters:
max
- the max- Returns:
- this
- Since:
- 3.5
-
getMin
public BsonDocument getMin()
Deprecated.Returns the minimum inclusive lower bound for a specific index. By default there is no min bound.- Returns:
- the min
- Since:
- 3.5
-
min
public FindOperation<T> min(BsonDocument min)
Deprecated.Sets the minimum inclusive lower bound for a specific index. A null value means no max is set.- Parameters:
min
- the min- Returns:
- this
- Since:
- 3.5
-
getMaxScan
@Deprecated public long getMaxScan()
Deprecated.Deprecated as of MongoDB 4.0 releaseReturns the maximum number of documents or index keys to scan when executing the query. A zero value or less will be ignored, and indicates that the driver should respect the server's default value.- Returns:
- the maxScan
- Since:
- 3.5
-
maxScan
@Deprecated public FindOperation<T> maxScan(long maxScan)
Deprecated.Deprecated as of MongoDB 4.0 releaseSets the maximum number of documents or index keys to scan when executing the query. A zero value or less will be ignored, and indicates that the driver should respect the server's default value.- Parameters:
maxScan
- the maxScan- Returns:
- this
- Since:
- 3.5
-
isReturnKey
public boolean isReturnKey()
Deprecated.Returns the returnKey. If true the find operation will return only the index keys in the resulting documents. Default value is false. If returnKey is true and the find command does not use an index, the returned documents will be empty.- Returns:
- the returnKey
- Since:
- 3.5
-
returnKey
public FindOperation<T> returnKey(boolean returnKey)
Deprecated.Sets the returnKey. If true the find operation will return only the index keys in the resulting documents.- Parameters:
returnKey
- the returnKey- Returns:
- this
- Since:
- 3.5
-
isShowRecordId
public boolean isShowRecordId()
Deprecated.Returns the showRecordId. Determines whether to return the record identifier for each document. If true, adds a field $recordId to the returned documents. The default is false.- Returns:
- the showRecordId
- Since:
- 3.5
-
showRecordId
public FindOperation<T> showRecordId(boolean showRecordId)
Deprecated.Sets the showRecordId. Set to true to add a field$recordId
to the returned documents.- Parameters:
showRecordId
- the showRecordId- Returns:
- this
- Since:
- 3.5
-
isSnapshot
@Deprecated public boolean isSnapshot()
Deprecated.Deprecated in MongoDB 3.6 release and removed in MongoDB 4.0 releaseReturns the snapshot. Prevents the cursor from returning a document more than once because of an intervening write operation. The default is false.- Returns:
- the snapshot
- Since:
- 3.5
-
snapshot
@Deprecated public FindOperation<T> snapshot(boolean snapshot)
Deprecated.Deprecated in MongoDB 3.6 release and removed in MongoDB 4.0 releaseSets the snapshot. If true it prevents the cursor from returning a document more than once because of an intervening write operation.- Parameters:
snapshot
- the snapshot- Returns:
- this
- Since:
- 3.5
-
retryReads
public FindOperation<T> retryReads(boolean retryReads)
Deprecated.Enables retryable reads if a read fails due to a network error.- Parameters:
retryReads
- true if reads should be retried- Returns:
- this
- Since:
- 3.11
-
getRetryReads
public boolean getRetryReads()
Deprecated.Gets the value for retryable reads. The default is true.- Returns:
- the retryable reads value
- Since:
- 3.11
-
execute
public BatchCursor<T> execute(ReadBinding binding)
Deprecated.Description copied from interface:ReadOperation
General execute which can return anything of type T- Specified by:
execute
in interfaceReadOperation<T>
- Parameters:
binding
- the binding to execute in the context of- Returns:
- T, the result of the execution
-
executeAsync
public void executeAsync(AsyncReadBinding binding, SingleResultCallback<AsyncBatchCursor<T>> callback)
Deprecated.Description copied from interface:AsyncReadOperation
General execute which can return anything of type T- Specified by:
executeAsync
in interfaceAsyncReadOperation<T>
- Parameters:
binding
- the binding to execute in the context ofcallback
- the callback to be called when the operation has been executed
-
asExplainableOperation
public ReadOperation<BsonDocument> asExplainableOperation(ExplainVerbosity explainVerbosity)
Deprecated.Gets an operation whose execution explains this operation.- Parameters:
explainVerbosity
- the explain verbosity- Returns:
- a read operation that when executed will explain this operation
-
asExplainableOperationAsync
public AsyncReadOperation<BsonDocument> asExplainableOperationAsync(ExplainVerbosity explainVerbosity)
Deprecated.Gets an operation whose execution explains this operation.- Parameters:
explainVerbosity
- the explain verbosity- Returns:
- a read operation that when executed will explain this operation
-
-