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
Allow one-to-many style lookups with via @DocumentReference.
This commit adds support for relational style One-To-Many references using a combination of ReadonlyProperty and @DocumentReference.
It allows to link types without explicitly storing the linking values within the document itself.
@document
class Publisher {
@id
ObjectId id;
// ...
@ReadOnlyProperty
@DocumentReference(lookup="{'publisherId':?#{#self._id} }")
List<Book> books;
}
Closes: #3798
Original pull request: #3802.
Copy file name to clipboardExpand all lines: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/DefaultReferenceResolver.java
+1-1
Original file line number
Diff line number
Diff line change
@@ -108,6 +108,6 @@ private Object createLazyLoadingProxy(MongoPersistentProperty property, Object s
Copy file name to clipboardExpand all lines: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MappingMongoConverter.java
Copy file name to clipboardExpand all lines: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/ReferenceLookupDelegate.java
+40-12
Original file line number
Diff line number
Diff line change
@@ -87,17 +87,20 @@ public ReferenceLookupDelegate(
87
87
* Read the reference expressed by the given property.
88
88
*
89
89
* @param property the reference defining property. Must not be {@literal null}. THe
90
-
* @param value the source value identifying to the referenced entity. Must not be {@literal null}.
90
+
* @param source the source value identifying to the referenced entity. Must not be {@literal null}.
91
91
* @param lookupFunction to execute a lookup query. Must not be {@literal null}.
92
92
* @param entityReader the callback to convert raw source values into actual domain types. Must not be
Copy file name to clipboardExpand all lines: spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateDocumentReferenceTests.java
0 commit comments