-
Notifications
You must be signed in to change notification settings - Fork 345
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
Return value of Repository.save
contains only added elements of @MappedCollection
, not existing ones
#1907
Comments
Please provide a Minimimal Reproducable Example, preferable as a Github repository. Make sure to include the database, either as an in memory database or if that is not possible using Testcontainers. |
Here's a reproduceable example as a GitHub repo: https://github.com/chris-unlikelyai/springdataissue Clone and run |
Analysis: For immutable entities we gather changed entities ( In the case of a collection of entities this leads to the effect you see, because we gather only those |
We gather immutable entities of which the id has changed, in order to set them as values in the parent entity. We now also gather unchanged entities. So they get set with the changed one in the parent. Closes #1907
Repository.save
contains only added elements of @MappedCollection
, not existing ones
I have two entities, one containing a
List
of the other, mapped to two tables using@MappedCollection
. There's a repository for the parent:If I have an existing entity in the database with a single child entity, loading it, adding a second child entity, and saving does the right thing in the database, but the parent entity returned by the
EntityRepository.save
method returns a list containing only the new child, not the original child plus the new child. Loading from the DB again returns the correct result.Full code to reproduce below:
The text was updated successfully, but these errors were encountered: