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
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Neo4jClient.BindSpec<S extends Neo4jClient.BindSpec<S>>
Contract for binding parameters to a query.static class
A builder forNeo4j clients
.static class
Indicates an illegal database name and is not translated into aDataAccessException
.static interface
static interface
Neo4jClient.OngoingBindSpec<T,
S extends Neo4jClient.BindSpec<S>> Ongoing bind specification.static interface
A contract for an ongoing delegation in the selected database.static interface
static interface
A runnable delegation.static interface
Contract for a runnable query that can be either run returning its result, run without results or be parameterized.static interface
Contract for a runnable query inside a dedicated database.static interface
Combination ofNeo4jClient.RunnableSpecBoundToDatabase
andNeo4jClient.RunnableSpecBoundToUser
, can't be bound any further.static interface
Contract for a runnable query bound to a user to be impersonated.static interface
Contract for a runnable query specification which still can be bound to a specific database and an impersonated user. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Neo4jClient
create
(org.neo4j.driver.Driver driver) static Neo4jClient
create
(org.neo4j.driver.Driver driver, DatabaseSelectionProvider databaseSelectionProvider) delegateTo
(Function<org.neo4j.driver.QueryRunner, Optional<T>> callback) Delegates interaction with the default database to the given callback.Returns the assigned database selection provider.default org.neo4j.driver.QueryRunner
default org.neo4j.driver.QueryRunner
getQueryRunner
(DatabaseSelection databaseSelection) 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).Entrypoint for creating a new Cypher query.Entrypoint for creating a new Cypher query based on a supplier.static String
verifyDatabaseName
(String databaseName) This is a utility method to verify and sanitize a database name.static Neo4jClient.Builder
with
(org.neo4j.driver.Driver driver)
-
Field Details
-
cypherLog
-
log
-
-
Method Details
-
create
-
create
static Neo4jClient create(org.neo4j.driver.Driver driver, DatabaseSelectionProvider databaseSelectionProvider) -
with
-
getQueryRunner
default org.neo4j.driver.QueryRunner getQueryRunner()- Returns:
- A managed query runner
- Since:
- 6.2
- See Also:
-
getQueryRunner
- 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
Returns the assigned database selection provider.- Returns:
- The database selection provider - can be null
-
verifyDatabaseName
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.
-