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
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceNeo4jClient.BindSpec<S extends Neo4jClient.BindSpec<S>>Contract for binding parameters to a query.static final classA builder forNeo4j clients.static final classIndicates an illegal database name and is not translated into aDataAccessException.static interfaceStep for defining the mapping.static interfaceNeo4jClient.OngoingBindSpec<T, S extends Neo4jClient.BindSpec<S>>Ongoing bind specification.static interfaceA contract for an ongoing delegation in the selected database.static interfaceFinal step that triggers fetching.static interfaceA runnable delegation.static interfaceContract for a runnable query that can be either run returning its result, run without results or be parameterized.static interfaceContract for a runnable query inside a dedicated database.static interfaceCombination ofNeo4jClient.RunnableSpecBoundToDatabaseandNeo4jClient.RunnableSpecBoundToUser, can't be bound any further.static interfaceContract for a runnable query bound to a user to be impersonated.static interfaceContract for a runnable query specification which still can be bound to a specific database and an impersonated user. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LogAccessorAll Cypher statements executed will be logged here.static final LogAccessorSome methods of theNeo4jClientwill be logged here.static final AtomicBooleanThis is a public API introduced to turn the logging of the infamous warning back on. -
Method Summary
Modifier and TypeMethodDescriptionstatic Neo4jClientcreate(org.neo4j.driver.Driver driver) static Neo4jClientcreate(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.@Nullable DatabaseSelectionProviderReturns the assigned database selection provider.default org.neo4j.driver.QueryRunnerRetrieves a query runner matching the plain Neo4j Java Driver api bound to Spring transactions.default org.neo4j.driver.QueryRunnergetQueryRunner(DatabaseSelection databaseSelection) Retrieves a query runner matching the plain Neo4j Java Driver api bound to Spring transactions configured to use a specific database.org.neo4j.driver.QueryRunnergetQueryRunner(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 @Nullable StringverifyDatabaseName(@Nullable String databaseName) This is a utility method to verify and sanitize a database name.static Neo4jClient.Builderwith(org.neo4j.driver.Driver driver)
-
Field Details
-
SUPPRESS_ID_DEPRECATIONS
This is a public API introduced to turn the logging of the infamous warning back on.The query used a deprecated function: `id`. -
cypherLog
All Cypher statements executed will be logged here. -
log
Some methods of theNeo4jClientwill be logged here.
-
-
Method Details
-
create
-
create
static Neo4jClient create(org.neo4j.driver.Driver driver, DatabaseSelectionProvider databaseSelectionProvider) -
with
-
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.
-
getQueryRunner
default org.neo4j.driver.QueryRunner getQueryRunner()Retrieves a query runner matching the plain Neo4j Java Driver api bound to Spring transactions.- Returns:
- a managed query runner
- Since:
- 6.2
- See Also:
-
getQueryRunner
Retrieves a query runner matching the plain Neo4j Java Driver api bound to Spring transactions configured to use a specific database.- Parameters:
databaseSelection- the database to use- 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 databaseasUser- 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
-