Class ReactiveNeo4jTemplate
java.lang.Object
org.springframework.data.neo4j.core.ReactiveNeo4jTemplate
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanClassLoaderAware
,org.springframework.beans.factory.BeanFactoryAware
,ReactiveFluentFindOperation
,ReactiveFluentNeo4jOperations
,ReactiveFluentSaveOperation
,ReactiveNeo4jOperations
@API(status=STABLE,
since="6.0")
public final class ReactiveNeo4jTemplate
extends Object
implements ReactiveNeo4jOperations, ReactiveFluentNeo4jOperations, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware
- Since:
- 6.0
- Author:
- Michael J. Simons, Gerrit Meier, Philipp Tölle
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.neo4j.core.ReactiveFluentFindOperation
ReactiveFluentFindOperation.ExecutableFind<T>, ReactiveFluentFindOperation.FindWithProjection<T>, ReactiveFluentFindOperation.FindWithQuery<T>, ReactiveFluentFindOperation.TerminatingFind<T>, ReactiveFluentFindOperation.TerminatingFindWithoutQuery<T>
Nested classes/interfaces inherited from interface org.springframework.data.neo4j.core.ReactiveFluentSaveOperation
ReactiveFluentSaveOperation.ExecutableSave<DT>
Nested classes/interfaces inherited from interface org.springframework.data.neo4j.core.ReactiveNeo4jOperations
ReactiveNeo4jOperations.ExecutableQuery<T>
-
Constructor Summary
ConstructorsConstructorDescriptionReactiveNeo4jTemplate
(ReactiveNeo4jClient neo4jClient, Neo4jMappingContext neo4jMappingContext) -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Long>
Counts the number of entities of a given type.reactor.core.publisher.Mono<Long>
Counts the number of entities of a given type.reactor.core.publisher.Mono<Long>
Counts the number of entities of a given type.reactor.core.publisher.Mono<Long>
count
(org.neo4j.cypherdsl.core.Statement statement) Counts the number of entities of a given type.reactor.core.publisher.Mono<Long>
Counts the number of entities of a given type.reactor.core.publisher.Mono<Void>
Delete all entities of a given type.<T> reactor.core.publisher.Mono<Void>
deleteAllById
(Iterable<?> ids, Class<T> domainType) Deletes all entities with one of the given ids, including all entities related to that entity.<T> reactor.core.publisher.Mono<Void>
deleteById
(Object id, Class<T> domainType) Deletes a single entity including all entities related to that entity.<T> reactor.core.publisher.Mono<Void>
deleteByIdWithVersion
(Object id, Class<T> domainType, Neo4jPersistentProperty versionProperty, Object versionValue) <T> reactor.core.publisher.Mono<Boolean>
existsById
(Object id, Class<T> domainType) Check if an entity for a given id exists in the database.Start creating a find operation for the given domainType.<T> reactor.core.publisher.Flux<T>
Load all entities of a given type.<T> reactor.core.publisher.Flux<T>
Load all entities of a given type by executing given statement.<T> reactor.core.publisher.Flux<T>
Load all entities of a given type by executing given statement with parameters.<T> reactor.core.publisher.Flux<T>
Load all entities of a given type by executing given statement.<T> reactor.core.publisher.Flux<T>
findAll
(org.neo4j.cypherdsl.core.Statement statement, Map<String, Object> parameters, Class<T> domainType) Load all entities of a given type by executing given statement with parameters.<T> reactor.core.publisher.Flux<T>
findAllById
(Iterable<?> ids, Class<T> domainType) Load all entities of a given type that are identified by the given ids.<T> reactor.core.publisher.Mono<T>
Load an entity from the database.<T> reactor.core.publisher.Mono<T>
Load one entity of a given type by executing given statement with parameters.<T> reactor.core.publisher.Mono<T>
findOne
(org.neo4j.cypherdsl.core.Statement statement, Map<String, Object> parameters, Class<T> domainType) Load one entity of a given type by executing given statement with parameters.Start creating a save operation for the given domainType.<T> reactor.core.publisher.Mono<T>
save
(T instance) Saves an instance of an entity, including all the related entities of the entity.<T> reactor.core.publisher.Flux<T>
Saves several instances of an entity, including all the related entities of the entity.<T,
R> reactor.core.publisher.Flux<R> Saves several instances of an entity, including the properties and relationship defined by the projectresultType
.<T> reactor.core.publisher.Flux<T>
saveAllAs
(Iterable<T> instances, BiPredicate<org.springframework.data.mapping.PropertyPath, Neo4jPersistentProperty> includeProperty) Saves several instances of an entity, using the provided predicate to shape the stored graph.<T,
R> reactor.core.publisher.Mono<R> Saves an instance of an entity, including the properties and relationship defined by the projectedresultType
.<T> reactor.core.publisher.Mono<T>
saveAs
(T instance, BiPredicate<org.springframework.data.mapping.PropertyPath, Neo4jPersistentProperty> includeProperty) Saves an instance of an entity, using the provided predicate to shape the stored graph.void
setBeanClassLoader
(ClassLoader classLoader) void
setBeanFactory
(org.springframework.beans.factory.BeanFactory beanFactory) <T> reactor.core.publisher.Mono<ReactiveNeo4jOperations.ExecutableQuery<T>>
toExecutableQuery
(Class<T> domainType, QueryFragmentsAndParameters queryFragmentsAndParameters) Create an executable query based on query fragment.<T> reactor.core.publisher.Mono<ReactiveNeo4jOperations.ExecutableQuery<T>>
toExecutableQuery
(PreparedQuery<T> preparedQuery) Takes a prepared query, containing all the information about the cypher template to be used, needed parameters and an optional mapping function, and turns it into an executable query.
-
Constructor Details
-
ReactiveNeo4jTemplate
public ReactiveNeo4jTemplate(ReactiveNeo4jClient neo4jClient, Neo4jMappingContext neo4jMappingContext)
-
-
Method Details
-
count
Description copied from interface:ReactiveNeo4jOperations
Counts the number of entities of a given type.- Specified by:
count
in interfaceReactiveNeo4jOperations
- Parameters:
domainType
- the type of the entities to be counted.- Returns:
- the number of instances stored in the database. Guaranteed to be not
null
.
-
count
Description copied from interface:ReactiveNeo4jOperations
Counts the number of entities of a given type.- Specified by:
count
in interfaceReactiveNeo4jOperations
- Parameters:
statement
- the CypherStatement
that returns the count.- Returns:
- the number of instances stored in the database. Guaranteed to be not
null
.
-
count
public reactor.core.publisher.Mono<Long> count(org.neo4j.cypherdsl.core.Statement statement, Map<String, Object> parameters) Description copied from interface:ReactiveNeo4jOperations
Counts the number of entities of a given type.- Specified by:
count
in interfaceReactiveNeo4jOperations
- Parameters:
statement
- the CypherStatement
that returns the count.parameters
- Map of parameters. Must not benull
.- Returns:
- the number of instances stored in the database. Guaranteed to be not
null
.
-
count
Description copied from interface:ReactiveNeo4jOperations
Counts the number of entities of a given type.- Specified by:
count
in interfaceReactiveNeo4jOperations
- Parameters:
cypherQuery
- the Cypher query that returns the count.- Returns:
- the number of instances stored in the database. Guaranteed to be not
null
.
-
count
Description copied from interface:ReactiveNeo4jOperations
Counts the number of entities of a given type.- Specified by:
count
in interfaceReactiveNeo4jOperations
- Parameters:
cypherQuery
- the Cypher query that returns the count.parameters
- Map of parameters. Must not benull
.- Returns:
- the number of instances stored in the database. Guaranteed to be not
null
.
-
findAll
Description copied from interface:ReactiveNeo4jOperations
Load all entities of a given type.- Specified by:
findAll
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entities. Must not benull
.- Parameters:
domainType
- the type of the entities. Must not benull
.- Returns:
- Guaranteed to be not
null
.
-
findAll
public <T> reactor.core.publisher.Flux<T> findAll(org.neo4j.cypherdsl.core.Statement statement, Class<T> domainType) Description copied from interface:ReactiveNeo4jOperations
Load all entities of a given type by executing given statement.- Specified by:
findAll
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entities. Must not benull
.- Parameters:
statement
- CypherStatement
. Must not benull
.domainType
- the type of the entities. Must not benull
.- Returns:
- Guaranteed to be not
null
.
-
findAll
public <T> reactor.core.publisher.Flux<T> findAll(org.neo4j.cypherdsl.core.Statement statement, Map<String, Object> parameters, Class<T> domainType) Description copied from interface:ReactiveNeo4jOperations
Load all entities of a given type by executing given statement with parameters.- Specified by:
findAll
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entities. Must not benull
.- Parameters:
statement
- CypherStatement
. Must not benull
.parameters
- Map of parameters. Must not benull
.domainType
- the type of the entities. Must not benull
.- Returns:
- Guaranteed to be not
null
.
-
findOne
public <T> reactor.core.publisher.Mono<T> findOne(org.neo4j.cypherdsl.core.Statement statement, Map<String, Object> parameters, Class<T> domainType) Description copied from interface:ReactiveNeo4jOperations
Load one entity of a given type by executing given statement with parameters.- Specified by:
findOne
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entities. Must not benull
.- Parameters:
statement
- CypherStatement
. Must not benull
.parameters
- Map of parameters. Must not benull
.domainType
- the type of the entities. Must not benull
.- Returns:
- Guaranteed to be not
null
.
-
findAll
Description copied from interface:ReactiveNeo4jOperations
Load all entities of a given type by executing given statement.- Specified by:
findAll
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entities. Must not benull
.- Parameters:
cypherQuery
- Cypher query string. Must not benull
.domainType
- the type of the entities. Must not benull
.- Returns:
- Guaranteed to be not
null
.
-
findAll
public <T> reactor.core.publisher.Flux<T> findAll(String cypherQuery, Map<String, Object> parameters, Class<T> domainType) Description copied from interface:ReactiveNeo4jOperations
Load all entities of a given type by executing given statement with parameters.- Specified by:
findAll
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entities. Must not benull
.- Parameters:
cypherQuery
- Cypher query string. Must not benull
.parameters
- Map of parameters. Must not benull
.domainType
- the type of the entities. Must not benull
.- Returns:
- Guaranteed to be not
null
.
-
findOne
public <T> reactor.core.publisher.Mono<T> findOne(String cypherQuery, Map<String, Object> parameters, Class<T> domainType) Description copied from interface:ReactiveNeo4jOperations
Load one entity of a given type by executing given statement with parameters.- Specified by:
findOne
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entities. Must not benull
.- Parameters:
cypherQuery
- Cypher query string. Must not benull
.parameters
- Map of parameters. Must not benull
.domainType
- the type of the entities. Must not benull
.- Returns:
- Guaranteed to be not
null
.
-
find
Description copied from interface:ReactiveFluentFindOperation
Start creating a find operation for the given domainType.- Specified by:
find
in interfaceReactiveFluentFindOperation
- Parameters:
domainType
- must not be null.- Returns:
- new instance of
ReactiveFluentFindOperation.ExecutableFind
.
-
existsById
Description copied from interface:ReactiveNeo4jOperations
Check if an entity for a given id exists in the database.- Specified by:
existsById
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entity.- Parameters:
id
- the id of the entity to check. Must not benull
.domainType
- the type of the entity. Must not benull
.- Returns:
- If entity exists in the database, true, otherwise false.
-
findById
Description copied from interface:ReactiveNeo4jOperations
Load an entity from the database.- Specified by:
findById
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entity.- Parameters:
id
- the id of the entity to load. Must not benull
.domainType
- the type of the entity. Must not benull
.- Returns:
- the loaded entity. Might return an empty optional.
-
findAllById
Description copied from interface:ReactiveNeo4jOperations
Load all entities of a given type that are identified by the given ids.- Specified by:
findAllById
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entities. Must not benull
.- Parameters:
ids
- of the entities identifying the entities to load. Must not benull
.domainType
- the type of the entities. Must not benull
.- Returns:
- Guaranteed to be not
null
.
-
toExecutableQuery
public <T> reactor.core.publisher.Mono<ReactiveNeo4jOperations.ExecutableQuery<T>> toExecutableQuery(Class<T> domainType, QueryFragmentsAndParameters queryFragmentsAndParameters) Description copied from interface:ReactiveNeo4jOperations
Create an executable query based on query fragment.- Specified by:
toExecutableQuery
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- The type of the objects returned by this query.- Parameters:
domainType
- domain class the executable query should returnqueryFragmentsAndParameters
- fragments and parameters to construct the query from- Returns:
- An executable query
-
save
public <T> reactor.core.publisher.Mono<T> save(T instance) Description copied from interface:ReactiveNeo4jOperations
Saves an instance of an entity, including all the related entities of the entity.- Specified by:
save
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entity.- Parameters:
instance
- the entity to be saved. Must not benull
.- Returns:
- the saved instance.
-
saveAs
public <T> reactor.core.publisher.Mono<T> saveAs(T instance, BiPredicate<org.springframework.data.mapping.PropertyPath, Neo4jPersistentProperty> includeProperty) Description copied from interface:ReactiveNeo4jOperations
Saves an instance of an entity, using the provided predicate to shape the stored graph. One can think of the predicate as a dynamic projection. If you want to save or update properties of associations (aka related nodes), you must include the association property as well (meaning the predicate must return true for that property, too).Be careful when reusing the returned instance for further persistence operations, as it will most likely not be fully hydrated and without using a static or dynamic projection, you will most likely cause data loss.
- Specified by:
saveAs
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entity.- Parameters:
instance
- the entity to be saved. Must not benull
.includeProperty
- A predicate to determine the properties to save.- Returns:
- the saved instance.
-
saveAs
Description copied from interface:ReactiveNeo4jOperations
Saves an instance of an entity, including the properties and relationship defined by the projectedresultType
.- Specified by:
saveAs
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entity.R
- the type of the projection to be used during save.- Parameters:
instance
- the entity to be saved. Must not benull
.- Returns:
- the saved, projected instance.
-
saveAll
Description copied from interface:ReactiveNeo4jOperations
Saves several instances of an entity, including all the related entities of the entity.- Specified by:
saveAll
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entity.- Parameters:
instances
- the instances to be saved. Must not benull
.- Returns:
- the saved instances.
-
saveAllAs
public <T> reactor.core.publisher.Flux<T> saveAllAs(Iterable<T> instances, BiPredicate<org.springframework.data.mapping.PropertyPath, Neo4jPersistentProperty> includeProperty) Description copied from interface:ReactiveNeo4jOperations
Saves several instances of an entity, using the provided predicate to shape the stored graph. One can think of the predicate as a dynamic projection. If you want to save or update properties of associations (aka related nodes), you must include the association property as well (meaning the predicate must return true for that property, too).Be careful when reusing the returned instances for further persistence operations, as they will most likely not be fully hydrated and without using a static or dynamic projection, you will most likely cause data loss.
- Specified by:
saveAllAs
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entity.- Parameters:
instances
- the instances to be saved. Must not benull
.includeProperty
- A predicate to determine the properties to save.- Returns:
- the saved instances.
-
saveAllAs
Description copied from interface:ReactiveNeo4jOperations
Saves several instances of an entity, including the properties and relationship defined by the projectresultType
.- Specified by:
saveAllAs
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entity.R
- the type of the projection to be used during save.- Parameters:
instances
- the instances to be saved. Must not benull
.- Returns:
- the saved, projected instance.
-
deleteAllById
Description copied from interface:ReactiveNeo4jOperations
Deletes all entities with one of the given ids, including all entities related to that entity.- Specified by:
deleteAllById
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entity.- Parameters:
ids
- the ids of the entities to be deleted. Must not benull
.domainType
- the type of the entity
-
deleteById
Description copied from interface:ReactiveNeo4jOperations
Deletes a single entity including all entities related to that entity.- Specified by:
deleteById
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- the type of the entity.- Parameters:
id
- the id of the entity to be deleted. Must not benull
.domainType
- the type of the entity
-
deleteByIdWithVersion
public <T> reactor.core.publisher.Mono<Void> deleteByIdWithVersion(Object id, Class<T> domainType, Neo4jPersistentProperty versionProperty, Object versionValue) - Specified by:
deleteByIdWithVersion
in interfaceReactiveNeo4jOperations
-
deleteAll
Description copied from interface:ReactiveNeo4jOperations
Delete all entities of a given type.- Specified by:
deleteAll
in interfaceReactiveNeo4jOperations
- Parameters:
domainType
- type of the entities to be deleted. Must not benull
.
-
toExecutableQuery
public <T> reactor.core.publisher.Mono<ReactiveNeo4jOperations.ExecutableQuery<T>> toExecutableQuery(PreparedQuery<T> preparedQuery) Description copied from interface:ReactiveNeo4jOperations
Takes a prepared query, containing all the information about the cypher template to be used, needed parameters and an optional mapping function, and turns it into an executable query.- Specified by:
toExecutableQuery
in interfaceReactiveNeo4jOperations
- Type Parameters:
T
- The type of the objects returned by this query.- Parameters:
preparedQuery
- prepared query that should get converted to an executable query- Returns:
- An executable query
-
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException - Specified by:
setBeanFactory
in interfaceorg.springframework.beans.factory.BeanFactoryAware
- Throws:
org.springframework.beans.BeansException
-
setBeanClassLoader
- Specified by:
setBeanClassLoader
in interfaceorg.springframework.beans.factory.BeanClassLoaderAware
-
save
Description copied from interface:ReactiveFluentSaveOperation
Start creating a save operation for the given domainType.- Specified by:
save
in interfaceReactiveFluentSaveOperation
- Parameters:
domainType
- must not be null.- Returns:
- new instance of
ReactiveFluentSaveOperation.ExecutableSave
.
-