I have an old-ish (3 years) service I need to maintain and just joined the team. It is a spring-webflux app with mongodb (4). All models are defined with lombok and where there are relations between them, @DBRef annotation was used. It works fine, but now I have to bump up spring (and the rest of the dependencies) and I just realized @DBRef is no longer supported.
Somehow, I understand the decision, but I couldn't find any straight forward alternative other than doing myself all the cascade operations.
So, is there any easier way to approach this?
Thanks.
@DBRefhas been replaced by@DocumentReferencesome time ago.@DocumentReference: Applied at the field to indicate it is to be stored as a pointer to another document. This can be a single value (theidby default), or a Document provided via a converter.This very simple example shows how it works:
For more details, have a look at the official docu:
https://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#mapping-usage-annotations