Interface DatabaseSelectionProvider
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A provider interface that knows in which database repositories or either the reactive or imperative template should
work.
An instance of a database name provider is only relevant when SDN is used with a Neo4j 4.0+ cluster or server.
To select the default database, return an empty optional. If you return a database name, it must not be empty. The empty optional indicates an unset database name on the client, so that the server can decide on the default to use.
The provider is asked before any interaction of a repository or template with the cluster or server. That means you can in theory return different database names for each interaction. Be aware that you might end up with no data on queries or data stored to wrong database if you don't pay meticulously attention to the database you interact with.
- Since:
- 6.0
- Author:
- Michael J. Simons
-
Method Summary
Modifier and TypeMethodDescriptionstatic DatabaseSelectionProvider
createStaticDatabaseSelectionProvider
(String databaseName) Creates a statically configured database selection provider always selecting the database with the given namedatabaseName
.static DatabaseSelectionProvider
A database selection provider always returning the default selection.
-
Method Details
-
getDatabaseSelection
DatabaseSelection getDatabaseSelection()- Returns:
- The selected database me to interact with. Use
DatabaseSelection.undecided()
to indicate the default database.
-
createStaticDatabaseSelectionProvider
Creates a statically configured database selection provider always selecting the database with the given namedatabaseName
.- Parameters:
databaseName
- The database name to use, must not be null nor empty.- Returns:
- A statically configured database name provider.
-
getDefaultSelectionProvider
A database selection provider always returning the default selection.- Returns:
- A provider for the default database name.
-