java.lang.Object
org.neo4j.driver.TransactionConfig
- All Implemented Interfaces:
Serializable
Configuration object containing settings for transactions.
Instances are immutable and can be reused for multiple transactions.
Configuration is supported for:
- queries executed in auto-commit transactions - using various overloads of
Session.run(String, TransactionConfig)
andAsyncSession.runAsync(String, TransactionConfig)
- transactions started by transaction functions - using
Session.executeWrite(TransactionCallback, TransactionConfig)
,Session.executeRead(TransactionCallback, TransactionConfig)
and the other similar variants - unmanaged transactions - using
Session.beginTransaction(TransactionConfig)
andAsyncSession.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();
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Builder used to constructtransaction configuration
objects. -
Method Summary
Modifier and TypeMethodDescriptionstatic TransactionConfig.Builder
builder()
Create newTransactionConfig.Builder
used to construct a configuration object.static TransactionConfig
empty()
Get a configuration object that does not have any values configures.boolean
int
hashCode()
boolean
isEmpty()
Check if this configuration object contains any values.metadata()
Get the configured transaction metadata.timeout()
Get the configured transaction timeout.toString()
-
Method Details
-
empty
Get a configuration object that does not have any values configures.- Returns:
- an empty configuration object.
-
builder
Create newTransactionConfig.Builder
used to construct a configuration object.- Returns:
- new builder.
-
timeout
Get the configured transaction timeout.- Returns:
- timeout or
null
when it is not configured.
-
metadata
Get the configured transaction metadata.- Returns:
- metadata or empty map when it is not configured.
-
isEmpty
public boolean isEmpty()Check if this configuration object contains any values.- Returns:
true
when no values are configured,false otherwise
.
-
equals
-
hashCode
public int hashCode() -
toString
-