Building blocks of Spring Data Neo4j
Overview
SDN 由可组合构建模块组成。它建立在 Neo4j Java Driver 的基础之上。Java 驱动程序的实例通过 Spring Boot 的自动配置本身提供。驱动程序的所有配置选项在名称空间 spring.neo4j
中都可以访问。驱动程序 bean 提供命令式、异步和响应方法来与 Neo4j 交互。
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.
您可以在该 bean 上使用驱动程序提供的所有事务方法,例如 auto-commit transactions、 transaction functions 和非托管事务。请注意,这些事务并不严格绑定到正在进行的 Spring 事务。
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 Data 和 Spring 平台或响应式事务管理器的集成始于 Neo4j Client。客户端是 SDN 的一部分,通过一个单独的启动程序 {artifactIdStarter}
进行配置。该启动程序的配置名称空间是 spring.data.neo4j
。
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, {artifactIdStarter}
.
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.
更高一级的抽象是 Neo4j 模板。它知道你的领域,你可以使用它来查询任意领域对象。模板在包含大量领域类或自定义查询的场景中非常有用,你不希望为每个领域类都创建一个额外的存储库抽象。
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 Data 存储库。
The highest level of abstraction is a Spring Data repository.
SDN 的所有抽象都以强制性和响应性时尚出现。不建议在同一应用程序中混合这两种编程样式。响应性基础结构需要 Neo4j 4.0+ 数据库。
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 |
---|---|
|
include::example$config/package-info.java[] |
|
include::example$core/package-info.java[] |
|
include::example$core/convert/package-info.java[] |
|
include::example$core/support/package-info.java[] |
|
include::example$core/transaction/package-info.java[] |
|
include::example$repository/package-info.java[] |
|
include::example$repository/config/package-info.java[] |
|
include::example$repository/support/package-info.java[] |