Interface Neo4jClient


@API(status=STABLE, since="6.0") public interface Neo4jClient
Definition of a modern Neo4j client.
Since:
6.0
Author:
Gerrit Meier, Michael J. Simons
  • Field Details

  • Method Details

    • create

      static Neo4jClient create(org.neo4j.driver.Driver driver)
    • create

      static Neo4jClient create(org.neo4j.driver.Driver driver, DatabaseSelectionProvider databaseSelectionProvider)
    • with

      static Neo4jClient.Builder with(org.neo4j.driver.Driver driver)
    • getQueryRunner

      default org.neo4j.driver.QueryRunner getQueryRunner()
      Returns:
      A managed query runner
      Since:
      6.2
      See Also:
    • getQueryRunner

      default org.neo4j.driver.QueryRunner getQueryRunner(DatabaseSelection databaseSelection)
      Returns:
      A managed query runner
      Since:
      6.2
      See Also:
    • getQueryRunner

      org.neo4j.driver.QueryRunner getQueryRunner(DatabaseSelection databaseSelection, UserSelection asUser)
      Retrieves a query runner that will participate in ongoing Spring transactions (either in declarative (implicit via @Transactional) or in programmatically (explicit via transaction template) ones). This runner can be used with the Cypher-DSL for example. If the client cannot retrieve an ongoing Spring transaction, this runner will use auto-commit semantics.
      Parameters:
      databaseSelection - The target database.
      asUser - As an impersonated user. Requires Neo4j 4.4 and Driver 4.4
      Returns:
      A managed query runner
      Since:
      6.2
    • query

      Entrypoint for creating a new Cypher query. Doesn't matter at this point whether it's a match, merge, create or removal of things.
      Parameters:
      cypher - The cypher code that shall be executed
      Returns:
      A runnable query specification.
    • query

      Entrypoint for creating a new Cypher query based on a supplier. Doesn't matter at this point whether it's a match, merge, create or removal of things. The supplier can be an arbitrary Supplier that may provide a DSL for generating the Cypher statement.
      Parameters:
      cypherSupplier - A supplier of arbitrary Cypher code
      Returns:
      A runnable query specification.
    • delegateTo

      <T> Neo4jClient.OngoingDelegation<T> delegateTo(Function<org.neo4j.driver.QueryRunner,Optional<T>> callback)
      Delegates interaction with the default database to the given callback.
      Type Parameters:
      T - The type of the result being produced
      Parameters:
      callback - A function receiving a statement runner for database interaction that can optionally return a result.
      Returns:
      A single result object or an empty optional if the callback didn't produce a result
    • getDatabaseSelectionProvider

      @Nullable DatabaseSelectionProvider getDatabaseSelectionProvider()
      Returns the assigned database selection provider.
      Returns:
      The database selection provider - can be null
    • verifyDatabaseName

      @Nullable static String verifyDatabaseName(@Nullable String databaseName)
      This is a utility method to verify and sanitize a database name.
      Parameters:
      databaseName - The database name to verify and sanitize
      Returns:
      A possibly trimmed name of the database.
      Throws:
      IllegalArgumentException - when the database name is not allowed with the underlying driver.