Class TransactionConfig.Builder

java.lang.Object
org.neo4j.driver.TransactionConfig.Builder
Enclosing class:
TransactionConfig

public static final class TransactionConfig.Builder extends Object
Builder used to construct transaction configuration objects.
  • Method Details

    • withTimeout

      public TransactionConfig.Builder withTimeout(Duration timeout)
      Set the transaction timeout. Transactions that execute longer than the configured timeout will be terminated by the database. See also withDefaultTimeout().

      This functionality allows user code to limit query/transaction execution time. The specified timeout overrides the default timeout configured in the database using the db.transaction.timeout setting (dbms.transaction.timeout before Neo4j 5.0). Values higher than db.transaction.timeout will be ignored and will fall back to the default for server versions between 4.2 and 5.2 (inclusive).

      The provided value should not represent a negative duration. Duration.ZERO will make the transaction execute indefinitely.

      Parameters:
      timeout - the timeout.
      Returns:
      this builder.
    • withDefaultTimeout

      public TransactionConfig.Builder withDefaultTimeout()
      Set the transaction timeout to the server-side configured default timeout. This is the default behaviour if withTimeout(java.time.Duration) has not been called. See also withTimeout(java.time.Duration).
      Returns:
      this builder.
    • withMetadata

      public TransactionConfig.Builder withMetadata(Map<String,?> metadata)
      Set the transaction metadata. Specified metadata will be attached to the executing transaction and visible in the output of dbms.listQueries and dbms.listTransactions procedures. It will also get logged to the query.log.

      This functionality makes it easier to tag transactions and is equivalent to dbms.setTXMetaData procedure.

      Provided value should not be null.

      Parameters:
      metadata - the metadata.
      Returns:
      this builder.
    • build

      public TransactionConfig build()
      Build the transaction configuration object using the specified settings.
      Returns:
      new transaction configuration object.