@@ -10,8 +10,8 @@ image:https://spring.io/badges/spring-data-neo4j/ga.svg[Spring Data Neo4j,link=h
|
||||
:artifactIdStarter: spring-boot-starter-data-neo4j
|
||||
|
||||
:neo4j-version: 4.1.5
|
||||
:spring-boot-version: 2.5.3
|
||||
:spring-data-neo4j-version: 6.1.3
|
||||
:spring-boot-version: 2.6.3
|
||||
:spring-data-neo4j-version: 6.2.1
|
||||
// end::properties[]
|
||||
|
||||
[abstract]
|
||||
|
||||
@@ -318,7 +318,7 @@ Thus we stay consistent with all other Spring Boot starters, that are actually p
|
||||
|
||||
==== Responsibilities
|
||||
|
||||
The starter and it's automatic configuration is responsible for configuring Spring Data Neo4j repositories and infrastructure.
|
||||
The starter and its automatic configuration is responsible for configuring Spring Data Neo4j repositories and infrastructure.
|
||||
It needs a configured Neo4j Java Driver and therefor is itself dependent on `org.neo4j.driver:neo4j-java-driver-spring-boot-starter`,
|
||||
the official starter for the Neo4j Java Driver.
|
||||
|
||||
|
||||
@@ -124,18 +124,21 @@ You're then ready to replace annotations:
|
||||
|`org.springframework.data.neo4j.annotation.UseBookmark`
|
||||
|No replacement, not needed
|
||||
|
||||
|`org.springframework.data.neo4j.annotation.QueryResult`
|
||||
|Use <<projections.sdn, projections>>; arbitrary result mapping not supported anymore
|
||||
|
||||
|===
|
||||
|
||||
NOTE: Several Neo4j-OGM annotations have not yet a corresponding annotation in SDN, some will never have.
|
||||
We will add to the list above as we support additional features.
|
||||
|
||||
[[migrating.bookmarks]]
|
||||
=== Bookmarkmanagement
|
||||
=== Bookmark management
|
||||
|
||||
Both `@EnableBookmarkManagement` and `@UseBookmark` as well as the `org.springframework.data.neo4j.bookmark.BookmarkManager`
|
||||
interface and its only implementation `org.springframework.data.neo4j.bookmark.CaffeineBookmarkManager` are gone and are not needed anymore.
|
||||
|
||||
SDN uses Bookmarks for all transactions, without configuration.
|
||||
SDN uses bookmarks for all transactions, without configuration.
|
||||
You can remove the bean declaration of `CaffeineBookmarkManager` as well as the dependency to `com.github.ben-manes.caffeine:caffeine`.
|
||||
|
||||
[[migrating.autoindex]]
|
||||
|
||||
@@ -317,6 +317,31 @@ Mono<Director> lily = client
|
||||
|
||||
`TypeSystem` gives access to the types the underlying Java driver used to fill the record.
|
||||
|
||||
[[neo4j-client.result-objects.mapping-functions]]
|
||||
==== Using domain-aware mapping functions
|
||||
|
||||
If you know that the result of the query will contain nodes that have entity definitions in your application,
|
||||
you can use the injectable `MappingContext` to retrieve their mapping functions and apply them during the mapping.
|
||||
|
||||
[[neo4j-client-reader.mapping-function]]
|
||||
[source,java]
|
||||
.Using an existing mapping function
|
||||
----
|
||||
BiFunction<TypeSystem, MapAccessor, Movie> mappingFunction = neo4jMappingContext.getRequiredMappingFunctionFor(Movie.class);
|
||||
Mono<Director> lily = client
|
||||
.query(""
|
||||
+ " MATCH (p:Person {name: $name}) - [:DIRECTED] -> (m:Movie)"
|
||||
+ "RETURN p, collect(m) as movies")
|
||||
.bind("Lilly Wachowski").to("name")
|
||||
.fetchAs(Director.class).mappedBy((TypeSystem t, Record record) -> {
|
||||
List<Movie> movies = record.get("movies")
|
||||
.asList(movie -> mappingFunction.apply(t, movie));
|
||||
return new Director(record.get("name").asString(), movies);
|
||||
})
|
||||
.one();
|
||||
----
|
||||
|
||||
|
||||
[[neo4j-client.interacting.driver.directly]]
|
||||
=== Interacting directly with the driver while using managed transactions
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ release.
|
||||
While patch versions of the Neo4j Java Driver are usually drop-in replacements, SDN6 makes sure that even minor versions
|
||||
are interchangeable as it checks for the presence or absence of methods or interface changes if necessary.
|
||||
|
||||
Therefore, you are able to use any 4.x Neo4j Java Driver with any SDN6 6.x version.
|
||||
Therefore, you are able to use any 4.x Neo4j Java Driver with any SDN 6.x version.
|
||||
|
||||
=== With Spring Boot
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
= Getting started
|
||||
|
||||
We provide a Spring Boot starter for SDN.
|
||||
Please include the starter module via your dependency management and configure the bolt URL to use, for example `org.neo4j.driver.uri=bolt://localhost:7687`.
|
||||
Please include the starter module via your dependency management and configure the bolt URL to use, for example `spring.neo4j.uri=bolt://localhost:7687`.
|
||||
The starter assumes that the server has disabled authentication.
|
||||
As the SDN starter depends on the starter for the Java Driver, all things regarding configuration said there, apply here as well.
|
||||
For a reference of the available properties, use your IDEs autocompletion in the `org.neo4j.driver` namespace or look at the link:{java-driver-starter-href}/blob/master/docs/manual/index.adoc[dedicated manual].
|
||||
For a reference of the available properties, use your IDEs autocompletion in the `spring.neo4j` namespace.
|
||||
|
||||
SDN supports
|
||||
|
||||
@@ -13,7 +13,7 @@ SDN supports
|
||||
* Reactive programming based on https://www.reactive-streams.org[Reactive Streams], including full support for https://spring.io/blog/2019/05/16/reactive-transactions-with-spring[reactive transactions].
|
||||
|
||||
Those are all included in the same binary.
|
||||
The reactive programming model requires a 4.0 Neo4j server on the database side and reactive Spring on the other hand.
|
||||
The reactive programming model requires a 4+ Neo4j server on the database side and reactive Spring on the other hand.
|
||||
|
||||
[[prepare-the-database]]
|
||||
== Prepare the database
|
||||
@@ -53,7 +53,7 @@ You can issue a _curl_ request against the Spring Initializer to create a basic
|
||||
.Create a basic Maven project with the Spring Initializr
|
||||
----
|
||||
curl https://start.spring.io/starter.tgz \
|
||||
-d dependencies=webflux,actuator,data-neo4j \
|
||||
-d dependencies=webflux,data-neo4j \
|
||||
-d bootVersion={spring-boot-version} \
|
||||
-d baseDir=Neo4jSpringBootExample \
|
||||
-d name=Neo4j%20SpringBoot%20Example | tar -xzvf -
|
||||
@@ -84,7 +84,7 @@ The idea is the same, just generate a Gradle project:
|
||||
.Create a basic Gradle project with the Spring Initializr
|
||||
----
|
||||
curl https://start.spring.io/starter.tgz \
|
||||
-d dependencies=webflux,actuator,data-neo4j \
|
||||
-d dependencies=webflux,data-neo4j \
|
||||
-d type=gradle-project \
|
||||
-d bootVersion={spring-boot-version} \
|
||||
-d baseDir=Neo4jSpringBootExampleGradle \
|
||||
|
||||
@@ -115,7 +115,7 @@ No.
|
||||
An embedded database is usually represented by an instance of `org.neo4j.graphdb.GraphDatabaseService` and has no Bolt connector out of the box.
|
||||
|
||||
SDN can however work very much with Neo4j's test harness, the test harness is specially meant to be a drop-in replacement for the real database.
|
||||
Support for both Neo4j 3.5 and 4.0 test harness is implemented via link:{java-driver-starter-href}[the Spring Boot starter for the driver].
|
||||
Support for both Neo4j 3.5 and 4.x test harness is implemented via link:{java-driver-starter-href}[the Spring Boot starter for the driver].
|
||||
Have a look at the corresponding module `org.neo4j.driver:neo4j-java-driver-test-harness-spring-boot-autoconfigure`.
|
||||
|
||||
[[sdn-without-spring-boot]]
|
||||
|
||||
@@ -287,6 +287,8 @@ We see the `MovieEntity` as the aggregate root, owning the relationships.
|
||||
On the other hand, we want to be able to pull all people from the database without selecting all the movies associated with them.
|
||||
Please consider your application's use case before you try to map every relationship in your database in every direction.
|
||||
While you can do this, you may end up rebuilding a graph database inside your object graph and this is not the intention of a mapping framework.
|
||||
If you have to model your circular or bidirectional domain and don't want to fetch the whole graph,
|
||||
you can define a fine-grained description of the data that you want to fetch by using <<projections.sdn, projections>>.
|
||||
|
||||
[[mapping.id-handling]]
|
||||
== Handling and provisioning of unique IDs
|
||||
|
||||
@@ -105,7 +105,7 @@ Also, 4.0 requires JDK 11.
|
||||
You need the following dependencies to run <<dataneo4jtest-harness35-example>>:
|
||||
|
||||
[source,xml]
|
||||
.Neo4j 4.0 test harness dependencies
|
||||
.Neo4j 3.5 test harness dependencies
|
||||
----
|
||||
<dependency>
|
||||
<groupId>org.neo4j.test</groupId>
|
||||
@@ -179,12 +179,12 @@ application properties. We overwrite the corresponding Neo4j settings.
|
||||
<.> Shutdown Neo4j after all tests.
|
||||
|
||||
[[dataneo4jtest-harness40]]
|
||||
=== `@DataNeo4jTest` with Neo4j test harness 4.0+
|
||||
=== `@DataNeo4jTest` with Neo4j test harness 4.x
|
||||
|
||||
You need the following dependencies to run <<dataneo4jtest-harness40-example>>:
|
||||
|
||||
[source,xml]
|
||||
.Neo4j 4.0 test harness dependencies
|
||||
.Neo4j 4.x test harness dependencies
|
||||
----
|
||||
<dependency>
|
||||
<groupId>org.neo4j.test</groupId>
|
||||
@@ -205,7 +205,7 @@ an appropriate repository configuration.
|
||||
|
||||
[[dataneo4jtest-harness40-example]]
|
||||
[source,java]
|
||||
.Using Neo4j 4.0+ test harness
|
||||
.Using Neo4j 4.x test harness
|
||||
----
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user