Class QueryConfig.Builder

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

public static final class QueryConfig.Builder extends Object
Builder used to configure QueryConfig which will be used to execute a query.
  • Method Details

    • withRouting

      public QueryConfig.Builder withRouting(RoutingControl routing)
      Set routing mode for the query.
      Parameters:
      routing - routing mode
      Returns:
      this builder
    • withDatabase

      public QueryConfig.Builder withDatabase(String database)
      Set target database for the query.
      Parameters:
      database - database
      Returns:
      this builder
    • withImpersonatedUser

      public QueryConfig.Builder withImpersonatedUser(String impersonatedUser)
      Set impersonated user for the query.
      Parameters:
      impersonatedUser - impersonated user
      Returns:
      this builder
    • withBookmarkManager

      public QueryConfig.Builder withBookmarkManager(BookmarkManager bookmarkManager)
      Set bookmark manager for the query.
      Parameters:
      bookmarkManager - bookmark manager
      Returns:
      this builder
    • withTimeout

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

      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.
      Since:
      5.16
    • withMetadata

      public QueryConfig.Builder withMetadata(Map<String,Serializable> metadata)
      Set the transaction metadata.
      Parameters:
      metadata - the metadata, must not be null.
      Returns:
      this builder.
      Since:
      5.16
    • build

      public QueryConfig build()
      Create a config instance from this builder.
      Returns:
      a new QueryConfig instance.