public class TransactionConfig extends Object implements Serializable
Configuration is supported for:
Session.run(String, TransactionConfig)
and
AsyncSession.runAsync(String, TransactionConfig)
Session.readTransaction(TransactionWork, TransactionConfig)
,
Session.writeTransaction(TransactionWork, TransactionConfig)
, AsyncSession.readTransactionAsync(AsyncTransactionWork, TransactionConfig)
and
AsyncSession.writeTransactionAsync(AsyncTransactionWork, TransactionConfig)
Session.beginTransaction(TransactionConfig)
and AsyncSession.beginTransactionAsync(TransactionConfig)
Creation of configuration objects can be done using the builder API:
Map<String, Object> metadata = new HashMap<>();
metadata.put("type", "update user");
metadata.put("application", "my application");
TransactionConfig config = TransactionConfig.builder()
.withTimeout(Duration.ofSeconds(4))
.withMetadata(metadata)
.build();
Session
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
TransactionConfig.Builder
Builder used to construct
transaction configuration objects. |
Modifier and Type | Method and Description |
---|---|
static TransactionConfig.Builder |
builder()
Create new
TransactionConfig.Builder used to construct a configuration object. |
static TransactionConfig |
empty()
Get a configuration object that does not have any values configures.
|
boolean |
equals(Object o) |
int |
hashCode() |
boolean |
isEmpty()
Check if this configuration object contains any values.
|
Map<String,Value> |
metadata()
Get the configured transaction metadata.
|
Duration |
timeout()
Get the configured transaction timeout.
|
String |
toString() |
public static TransactionConfig empty()
public static TransactionConfig.Builder builder()
TransactionConfig.Builder
used to construct a configuration object.public Duration timeout()
null
when it is not configured.public Map<String,Value> metadata()
public boolean isEmpty()
true
when no values are configured, false otherwise
.