Package com.mongodb
Class ClientSessionOptions.Builder
java.lang.Object
com.mongodb.ClientSessionOptions.Builder
- Enclosing class:
- ClientSessionOptions
A builder for instances of
ClientSession
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build the session options instance.causallyConsistent
(boolean causallyConsistent) Sets whether operations using the session should causally consistent with each other.defaultTimeout
(long defaultTimeout, TimeUnit timeUnit) Sets the default time limit for the following operations executed on the session:commitTransaction
abortTransaction
withTransaction
close
defaultTransactionOptions
(TransactionOptions defaultTransactionOptions) Sets whether operations using the session should causally consistent with each other.snapshot
(boolean snapshot) Sets whether read operations using the session should share the same snapshot.
-
Method Details
-
causallyConsistent
Sets whether operations using the session should causally consistent with each other.- Parameters:
causallyConsistent
- whether operations using the session should be causally consistent- Returns:
- this
- MongoDB documentation
- Causal Consistency
-
snapshot
Sets whether read operations using the session should share the same snapshot.The default value is unset, in which case the driver will use the global default value, which is currently false.
- Parameters:
snapshot
- true for snapshot reads, false otherwise- Returns:
- this
- Since:
- 4.3
- MongoDB documentation
- Snapshot reads
- Since server release
- 5.0
-
defaultTransactionOptions
public ClientSessionOptions.Builder defaultTransactionOptions(TransactionOptions defaultTransactionOptions) Sets whether operations using the session should causally consistent with each other.- Parameters:
defaultTransactionOptions
- the default transaction options to use for all transactions on this session,- Returns:
- this
- Since:
- 3.8
- Since server release
- 4.0
-
defaultTimeout
@Alpha(CLIENT) public ClientSessionOptions.Builder defaultTimeout(long defaultTimeout, TimeUnit timeUnit) Sets the default time limit for the following operations executed on the session:commitTransaction
abortTransaction
withTransaction
close
- Parameters:
defaultTimeout
- the timeouttimeUnit
- the time unit- Returns:
- this
- Since:
- 5.2
- See Also:
-
build
Build the session options instance.- Returns:
- The
ClientSessionOptions
-