You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/DocumentReferenceSource.java
+23-2
Original file line number
Diff line number
Diff line change
@@ -28,11 +28,11 @@ public class DocumentReferenceSource {
28
28
29
29
privatefinalObjectself;
30
30
31
-
@NullableprivatefinalObjecttargetSource;
31
+
privatefinal@NullableObjecttargetSource;
32
32
33
33
/**
34
34
* Create a new instance of {@link DocumentReferenceSource}.
35
-
*
35
+
*
36
36
* @param self the entire wrapper object holding references. Must not be {@literal null}.
37
37
* @param targetSource the reference value source.
38
38
*/
@@ -60,4 +60,25 @@ public Object getSelf() {
60
60
publicObjectgetTargetSource() {
61
61
returntargetSource;
62
62
}
63
+
64
+
/**
65
+
* Dereference a {@code targetSource} if it is a {@link DocumentReferenceSource} or return {@code source} otherwise.
Copy file name to clipboardExpand all lines: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/ReferenceLookupDelegate.java
Copy file name to clipboardExpand all lines: src/main/asciidoc/reference/document-references.adoc
+4-3
Original file line number
Diff line number
Diff line change
@@ -263,7 +263,7 @@ class Publisher {
263
263
====
264
264
265
265
It is also possible to model relational style _One-To-Many_ references using a combination of `@ReadonlyProperty` and `@DocumentReference`.
266
-
This approach allows to link types without explicitly storing the linking values within the document itself as shown in the snipped below.
266
+
This approach allows link types without storing the linking values within the owning document but rather on the referencing document as shown in the example below.
267
267
268
268
====
269
269
[source,java]
@@ -313,8 +313,9 @@ class Publisher {
313
313
"name" : "Del Rey"
314
314
}
315
315
----
316
-
<1> Set up the link from `Book` to `Publisher` by storing the `Publisher.id` within the `Book` document.
317
-
<2> Mark the property holding the references to be read only. This prevents storing references to individual ``Book``s with the `Publisher` document.
316
+
<1> Set up the link from `Book` (reference) to `Publisher` (owner) by storing the `Publisher.id` within the `Book` document.
317
+
<2> Mark the property holding the references to be readonly.
318
+
This prevents storing references to individual ``Book``s with the `Publisher` document.
318
319
<3> Use the `#self` variable to access values within the `Publisher` document and in this retrieve `Books` with matching `publisherId`.
0 commit comments