Interface ExecutableStatement

All Known Subinterfaces:
ExecutableResultStatement, ReactiveExecutableResultStatement, ReactiveExecutableStatement

@API(status=STABLE, since="2021.2.1") public interface ExecutableStatement
This interface spots several methods that allow statements to be used with an instance of the Neo4j Java Driver. To use any of the executeWithXXX methods, the driver must be present on the class path. The corresponding Java module is org.neo4j.driver.

An ExecutableResultStatement makes a ResultStatement executable.

We don't add any overhead to the process but only use what's already there. The QueryRunner passed to any of the methods can be a session, a transaction or also the Spring Data Neo4j specific query runner.

We don't commit or rollback any transaction nor do we close a session. That is up to the caller.

Any parameter in this statement containing a value will be passed directly to the driver. The driver does a relatively good job converting most parameters. If in doubt or the result is wrong, use an appropriate overload of org.neo4j.driver.Values#value(parameter) to convert the parameter.

Use any of the of(Statement) or makeExecutable(Statement) methods to get an appropriate instance. The of methods are useful when you are using qualified imports, the makeExecutable-variant comes in handy with static imports.

Since:
2021.2.1
Author:
Michael J. Simons
  • Method Details

    • makeExecutable

      static ExecutableStatement makeExecutable(Statement statement)
      Creates an executable statement based on the given statement
      Parameters:
      statement - Any Cypher-DSL statement
      Returns:
      An executable statement. Maybe a ExecutableResultStatement, depending on the input.
      See Also:
    • makeExecutable

      static ExecutableResultStatement makeExecutable(ResultStatement statement)
      Creates an executable result statement based on the given statement
      Parameters:
      statement - A Cypher-DSL result statement
      Returns:
      An executable result statement.
      See Also:
    • of

      static ExecutableStatement of(Statement statement)
      Creates an executable statement based on the given statement
      Parameters:
      statement - Any Cypher-DSL statement
      Returns:
      An executable statement. Maybe a ExecutableResultStatement, depending on the input.
      See Also:
    • of

      Creates an executable result statement based on the given statement
      Parameters:
      statement - A Cypher-DSL result statement
      Returns:
      An executable result statement.
      See Also:
    • getParameters

      @NotNull @Contract(pure=true) @NotNull Map<String,Object> getParameters()
      Returns:
      A map of all parameters with a bound value.
      See Also:
    • getParameterNames

      @NotNull @Contract(pure=true) @NotNull Collection<String> getParameterNames()
      Returns:
      A set of parameter names being used.
      See Also:
    • getCypher

      @NotNull @Contract(pure=true) @NotNull String getCypher()
      Returns:
      A valid Cypher statement
      See Also:
    • executeWith

      org.neo4j.driver.summary.ResultSummary executeWith(org.neo4j.driver.SimpleQueryRunner queryRunner)
      If the Neo4j Java Driver is on the classpath, this method can be used to pass a QueryRunner to the statement, execute it and retrieve a result summary.

      All parameters with given values will be passed to the database. Please have a look at ResultStatement for further details about parameter conversions

      No resources passed to this method (neither sessions, transactions nor other query runners) will be closed. Resources opened inside the method will be closed.

      Parameters:
      queryRunner - a query runner
      Returns:
      A result summary (including server information, counters etc).
    • executeWith

      CompletableFuture<org.neo4j.driver.summary.ResultSummary> executeWith(org.neo4j.driver.async.AsyncQueryRunner queryRunner)
      If the Neo4j Java Driver is on the classpath, this method can be used to pass a QueryRunner to the statement, execute it and retrieve a result summary in an asynchronous fashion

      All parameters with given values will be passed to the database. Please have a look at ResultStatement for further details about parameter conversions

      No resources passed to this method (neither sessions, transactions nor other query runners) will be closed. Resources opened inside the method will be closed.

      Parameters:
      queryRunner - a query runner
      Returns:
      A completable future of a result summary (including server information, counters etc).