Is there a pattern for Spring Data Mongo to support persisting a link to a separate document in separate collection and having it re-hydrate automagically when its pulled back out of the database?
@Document
class Person <-- Saves to the Person Collection
@id
UUID id
String name
Address address
@Document
class Address --
@id
UUID id
String address1
...
Calling save(person) I'd want the address property in the database to reflect the Address Id, and have the address object persisted to the address collection. When I pull the Person back out, Address would be a fully hydrated (or maybe lazily?) and accessible.
- Spring Data Mongo 3.1
- Spring Boot 2.4
- Groovy 2.5
- JDK11