Open
Description
The Extended Reference data modeling pattern in MongoDB is one of the most popular and most powerful, but it's difficult to implement in Spring due to lack of support.
Im recommending creating two new annotations @ExtendedReference
and @ExtendedAttribute
to support this.
@ExtendedReference
would be applied to a embedded object and used to identify that
- The object needed to be persisted as an embedded document to the parent
- The
@Id
or_id
of the child object should always be included in the embedded fields - Only fields annotated with
@ExtendedAttribute
or with@Id
or@MongoId
should be persisted.
Fields with the @ExtendedReference
annotation should never be retrieved via $lookup
but if needed could be explicitly retrieved and set into the parent object.
This would allow users to take advantage of the extended reference pattern without
- Creating new custom POJO's to represent the smaller version of the class
- Having to do extensive custom serialization work
- Impact any of the existing query operations in the spring-data library.