This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Data Neo4j 7.4.0!spring-doc.cn

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.spring-doc.cn

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.spring-doc.cn

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.spring-doc.cn

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.spring-doc.cn

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.spring-doc.cn

The highest level of abstraction is a Spring Data repository.spring-doc.cn

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.spring-doc.cn

image$sdn buildingblocks
Figure 1. SDN building blocks

The template mechanism is similar to the templates of others stores. Find some more information about it in our FAQ. The Neo4j Client as such is unique to SDN. You will find its documentation in the appendix.spring-doc.cn

On the package level

Package Description

org.springframework.data.neo4j.configspring-doc.cn

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.spring-doc.cn

org.springframework.data.neo4j.corespring-doc.cn

This package contains the core infrastructure for creating an imperative or reactive client that can execute queries. Packages marked as @API(status = API.Status.STABLE) are safe to be used. The core package provides access to both the imperative and reactive variants of the client and the template.spring-doc.cn

org.springframework.data.neo4j.core.convertspring-doc.cn

Provides a set of simples types that SDN supports. The Neo4jConversions allows bringing in additional, custom converters.spring-doc.cn

org.springframework.data.neo4j.core.supportspring-doc.cn

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.spring-doc.cn

org.springframework.data.neo4j.core.transactionspring-doc.cn

Contains the core infrastructure for translating unmanaged Neo4j transaction into Spring managed transactions. Exposes both the imperative and reactive TransactionManager as Neo4jTransactionManager and ReactiveNeo4jTransactionManager.spring-doc.cn

org.springframework.data.neo4j.repositoryspring-doc.cn

This package provides the Neo4j imperative and reactive repository API.spring-doc.cn

org.springframework.data.neo4j.repository.configspring-doc.cn

Configuration infrastructure for Neo4j specific repositories, especially dedicated annotations to enable imperative and reactive Spring Data Neo4j repositories.spring-doc.cn

org.springframework.data.neo4j.repository.supportspring-doc.cn

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.spring-doc.cn