-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with replacement of @DBRef to @DocumentReference #4670
Comments
Thank you for reaching out! |
Hello @christophstrobl! Thank you for your answer! https://docs.spring.io/spring-data/mongodb/docs/current-SNAPSHOT/reference/html/#mapping-usage.document-references So there is expectation after reading of documentation above that combination of |
Hello @christophstrobl! Could you please share plans regarding this issue taking into account my last comment? |
Hello!
I would like to describe a problem with replacement of annotation
@DBRef
to annotation@DocumentReference
in case old data in MongoDB exist. For this purpose I have created a project with reproducing of this problem: https://github.com/ALGA0887/reference.git.So lets imagine the following class in previous releases of some application:
Here there is a
@DBRef
to the list ofOrderItem
:OrderItem
itself also contains information aboutguestIds
.So in previous releases
guests
were saved in MongoDB withDBRef
toorderItems
.In current release it was decided not to have a field
orderItems
inguests
collection since it is overhead. And it was planned to change the annotation@DBRef
to annotation@DocumentReference
in the following way:For new records in
guests
such changes work as expected (testcom.alga.reference.ReferenceApplicationTests#testLoadGuestWithoutDbRef
). But old records can't be read with the following exception:So my question is why
DBRef
is taken into account in lookup expression? Is it bug in reference resolving?In my project I have tried the following workaround and it works:
But if we imagine that migration of data is impossible (I mean remove
DBRef
for old records inguests
) then how we can apply such changes without any workaround at all?To reproduce a problem just comment
@ActiveProfiles(value = "workaround")
inReferenceApplicationTests
and run testtestLoadGuestWithDbRef
.The text was updated successfully, but these errors were encountered: