For the latest stable version, please use Spring Data Neo4j 7.3.4! |
Building blocks of Spring Data Neo4j
Overview
SDN consists of composable building blocks.
It builds on top of the Neo4j Java Driver.
The instance of the Java driver is provided through Spring Boot’s automatic configuration itself.
All configuration options of the driver are accessible in the namespace spring.neo4j
.
The driver bean provides imperative, asynchronous and reactive methods to interact with Neo4j.
You can use all transaction methods the driver provides on that bean such as auto-commit transactions, transaction functions and unmanaged transactions. Be aware that those transactions are not tight to an ongoing Spring transaction.
Integration with Spring Data and Spring’s platform or reactive transaction manager starts at the Neo4j Client.
The client is part of SDN is configured through a separate starter, spring-boot-starter-data-neo4j
.
The configuration namespace of that starter is spring.data.neo4j
.
The client is mapping agnostic. It doesn’t know about your domain classes, and you are responsible for mapping a result to an object suiting your needs.
The next higher level of abstraction is the Neo4j Template. It is aware of your domain, and you can use it to query arbitrary domain objects. The template comes in handy in scenarios with a large number of domain classes or custom queries for which you don’t want to create an additional repository abstraction each.
The highest level of abstraction is a Spring Data repository.
All abstractions of SDN come in both imperative and reactive fashions. It is not recommended mixing both programming styles in the same application. The reactive infrastructure requires a Neo4j 4.0+ database.
On the package level
Package | Description |
---|---|
|
This package contains configuration related support classes that can be used for application specific, annotated configuration classes. The abstract base classes are helpful if you don’t rely on Spring Boot’s autoconfiguration. The package provides some additional annotations that enable auditing. |
|
This package contains the core infrastructure for creating an imperative or reactive client that can execute queries.
Packages marked as |
|
Provides a set of simples types that SDN supports. The |
|
This package provides a couple of support classes that might be helpful in your domain, for example a predicate indicating that some transaction may be retried and additional converters and id generators. |
|
Contains the core infrastructure for translating unmanaged Neo4j transaction into Spring managed transactions. Exposes
both the imperative and reactive |
|
This package provides the Neo4j imperative and reactive repository API. |
|
Configuration infrastructure for Neo4j specific repositories, especially dedicated annotations to enable imperative and reactive Spring Data Neo4j repositories. |
|
This package provides a couple of public support classes for building custom imperative and reactive Spring Data Neo4j repository base classes. The support classes are the same classes used by SDN itself. |