Skip to content

Commit d7c473a

Browse files
committed
GH-2472 - Reference projection chapter from migration.
Closes #2472
1 parent a9ddc46 commit d7c473a

File tree

9 files changed

+46
-16
lines changed

9 files changed

+46
-16
lines changed

README.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ image:https://spring.io/badges/spring-data-neo4j/ga.svg[Spring Data Neo4j,link=h
1010
:artifactIdStarter: spring-boot-starter-data-neo4j
1111

1212
:neo4j-version: 4.1.5
13-
:spring-boot-version: 2.5.3
14-
:spring-data-neo4j-version: 6.1.3
13+
:spring-boot-version: 2.6.3
14+
:spring-data-neo4j-version: 6.2.1
1515
// end::properties[]
1616

1717
[abstract]

etc/adr/general-discussion.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ Thus we stay consistent with all other Spring Boot starters, that are actually p
318318

319319
==== Responsibilities
320320

321-
The starter and it's automatic configuration is responsible for configuring Spring Data Neo4j repositories and infrastructure.
321+
The starter and its automatic configuration is responsible for configuring Spring Data Neo4j repositories and infrastructure.
322322
It needs a configured Neo4j Java Driver and therefor is itself dependent on `org.neo4j.driver:neo4j-java-driver-spring-boot-starter`,
323323
the official starter for the Neo4j Java Driver.
324324

src/main/asciidoc/appendix/migrating.adoc

+5-2
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,21 @@ You're then ready to replace annotations:
124124
|`org.springframework.data.neo4j.annotation.UseBookmark`
125125
|No replacement, not needed
126126

127+
|`org.springframework.data.neo4j.annotation.QueryResult`
128+
|Use <<projections.sdn, projections>>; arbitrary result mapping not supported anymore
129+
127130
|===
128131

129132
NOTE: Several Neo4j-OGM annotations have not yet a corresponding annotation in SDN, some will never have.
130133
We will add to the list above as we support additional features.
131134

132135
[[migrating.bookmarks]]
133-
=== Bookmarkmanagement
136+
=== Bookmark management
134137

135138
Both `@EnableBookmarkManagement` and `@UseBookmark` as well as the `org.springframework.data.neo4j.bookmark.BookmarkManager`
136139
interface and its only implementation `org.springframework.data.neo4j.bookmark.CaffeineBookmarkManager` are gone and are not needed anymore.
137140

138-
SDN uses Bookmarks for all transactions, without configuration.
141+
SDN uses bookmarks for all transactions, without configuration.
139142
You can remove the bean declaration of `CaffeineBookmarkManager` as well as the dependency to `com.github.ben-manes.caffeine:caffeine`.
140143

141144
[[migrating.autoindex]]

src/main/asciidoc/appendix/neo4j-client.adoc

+25
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,31 @@ Mono<Director> lily = client
317317

318318
`TypeSystem` gives access to the types the underlying Java driver used to fill the record.
319319

320+
[[neo4j-client.result-objects.mapping-functions]]
321+
==== Using domain-aware mapping functions
322+
323+
If you know that the result of the query will contain nodes that have entity definitions in your application,
324+
you can use the injectable `MappingContext` to retrieve their mapping functions and apply them during the mapping.
325+
326+
[[neo4j-client-reader.mapping-function]]
327+
[source,java]
328+
.Using an existing mapping function
329+
----
330+
BiFunction<TypeSystem, MapAccessor, Movie> mappingFunction = neo4jMappingContext.getRequiredMappingFunctionFor(Movie.class);
331+
Mono<Director> lily = client
332+
.query(""
333+
+ " MATCH (p:Person {name: $name}) - [:DIRECTED] -> (m:Movie)"
334+
+ "RETURN p, collect(m) as movies")
335+
.bind("Lilly Wachowski").to("name")
336+
.fetchAs(Director.class).mappedBy((TypeSystem t, Record record) -> {
337+
List<Movie> movies = record.get("movies")
338+
.asList(movie -> mappingFunction.apply(t, movie));
339+
return new Director(record.get("name").asString(), movies);
340+
})
341+
.one();
342+
----
343+
344+
320345
[[neo4j-client.interacting.driver.directly]]
321346
=== Interacting directly with the driver while using managed transactions
322347

src/main/asciidoc/faq/faq.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ release.
1212
While patch versions of the Neo4j Java Driver are usually drop-in replacements, SDN6 makes sure that even minor versions
1313
are interchangeable as it checks for the presence or absence of methods or interface changes if necessary.
1414

15-
Therefore, you are able to use any 4.x Neo4j Java Driver with any SDN6 6.x version.
15+
Therefore, you are able to use any 4.x Neo4j Java Driver with any SDN 6.x version.
1616

1717
=== With Spring Boot
1818

src/main/asciidoc/getting-started/getting-started.adoc

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
= Getting started
33

44
We provide a Spring Boot starter for SDN.
5-
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`.
5+
Please include the starter module via your dependency management and configure the bolt URL to use, for example `spring.neo4j.uri=bolt://localhost:7687`.
66
The starter assumes that the server has disabled authentication.
77
As the SDN starter depends on the starter for the Java Driver, all things regarding configuration said there, apply here as well.
8-
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].
8+
For a reference of the available properties, use your IDEs autocompletion in the `spring.neo4j` namespace.
99

1010
SDN supports
1111

1212
* The well known and understood imperative programming model (much like Spring Data JDBC or JPA)
1313
* 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].
1414

1515
Those are all included in the same binary.
16-
The reactive programming model requires a 4.0 Neo4j server on the database side and reactive Spring on the other hand.
16+
The reactive programming model requires a 4+ Neo4j server on the database side and reactive Spring on the other hand.
1717

1818
[[prepare-the-database]]
1919
== Prepare the database
@@ -53,7 +53,7 @@ You can issue a _curl_ request against the Spring Initializer to create a basic
5353
.Create a basic Maven project with the Spring Initializr
5454
----
5555
curl https://start.spring.io/starter.tgz \
56-
-d dependencies=webflux,actuator,data-neo4j \
56+
-d dependencies=webflux,data-neo4j \
5757
-d bootVersion={spring-boot-version} \
5858
-d baseDir=Neo4jSpringBootExample \
5959
-d name=Neo4j%20SpringBoot%20Example | tar -xzvf -
@@ -84,7 +84,7 @@ The idea is the same, just generate a Gradle project:
8484
.Create a basic Gradle project with the Spring Initializr
8585
----
8686
curl https://start.spring.io/starter.tgz \
87-
-d dependencies=webflux,actuator,data-neo4j \
87+
-d dependencies=webflux,data-neo4j \
8888
-d type=gradle-project \
8989
-d bootVersion={spring-boot-version} \
9090
-d baseDir=Neo4jSpringBootExampleGradle \

src/main/asciidoc/introduction-and-preface/preface.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ No.
115115
An embedded database is usually represented by an instance of `org.neo4j.graphdb.GraphDatabaseService` and has no Bolt connector out of the box.
116116

117117
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.
118-
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].
118+
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].
119119
Have a look at the corresponding module `org.neo4j.driver:neo4j-java-driver-test-harness-spring-boot-autoconfigure`.
120120

121121
[[sdn-without-spring-boot]]

src/main/asciidoc/object-mapping/mapping.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ We see the `MovieEntity` as the aggregate root, owning the relationships.
287287
On the other hand, we want to be able to pull all people from the database without selecting all the movies associated with them.
288288
Please consider your application's use case before you try to map every relationship in your database in every direction.
289289
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.
290+
If you have to model your circular or bidirectional domain and don't want to fetch the whole graph,
291+
you can define a fine-grained description of the data that you want to fetch by using <<projections.sdn, projections>>.
290292

291293
[[mapping.id-handling]]
292294
== Handling and provisioning of unique IDs

src/main/asciidoc/testing/testing.adoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Also, 4.0 requires JDK 11.
105105
You need the following dependencies to run <<dataneo4jtest-harness35-example>>:
106106

107107
[source,xml]
108-
.Neo4j 4.0 test harness dependencies
108+
.Neo4j 3.5 test harness dependencies
109109
----
110110
<dependency>
111111
<groupId>org.neo4j.test</groupId>
@@ -179,12 +179,12 @@ application properties. We overwrite the corresponding Neo4j settings.
179179
<.> Shutdown Neo4j after all tests.
180180

181181
[[dataneo4jtest-harness40]]
182-
=== `@DataNeo4jTest` with Neo4j test harness 4.0+
182+
=== `@DataNeo4jTest` with Neo4j test harness 4.x
183183

184184
You need the following dependencies to run <<dataneo4jtest-harness40-example>>:
185185

186186
[source,xml]
187-
.Neo4j 4.0 test harness dependencies
187+
.Neo4j 4.x test harness dependencies
188188
----
189189
<dependency>
190190
<groupId>org.neo4j.test</groupId>
@@ -205,7 +205,7 @@ an appropriate repository configuration.
205205

206206
[[dataneo4jtest-harness40-example]]
207207
[source,java]
208-
.Using Neo4j 4.0+ test harness
208+
.Using Neo4j 4.x test harness
209209
----
210210
import static org.assertj.core.api.Assertions.assertThat;
211211

0 commit comments

Comments
 (0)