-
Notifications
You must be signed in to change notification settings - Fork 563
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
How to update aggregate collections? #2324
Comments
I think I've fixed it.
If the association is bidirectional it's not enough to define
Maybe you can try to implement a custom collection deserializer (here is a an example of its registration). Or you can research But I was not successful at that and found another solution. You can just replace
In that case collections in DB and JSON are merged successfuly. All tests are passed. Some things to note:
I tried to replace |
Here is a sample project
There are two entities:
One repository for the aggregate root entity:
And the configuration:
I need to create/update the whole aggregate entity using one HTTP request. There is a number of tests. Some of them works fine, but I have the following questions/problems.
It works, but I have to do two requests. At first create the parent entity, get its URL. And after that I can add child entities, because I have to specify a parent URL for them. Is it possible to use one request without parent URLs?
I get the exception:
java.lang.IllegalStateException: Multiple representations of the same entity [com.example.aggregatecollection.Child#1] are being merged. Detached: [com.example.aggregatecollection.Child@727dc2d6]; Managed: [com.example.aggregatecollection.Child@25f23f02]
The is no any exceptions. But no DELETE SQL statement is executed at all.
The interesting thing is that it works differently on my full project. Child entities are added successfully. And also the last child entity in the list is deleted. The only problem on my real project is that an entity in the middle of the aggregate collection is not deleted, because instead of a DELETE SQL statement an UPDATE statement is executed. I have no idea how to repeat that behaviour on a small sample project. So i think that at first I should try to fix the sample project. Could you please help? Should it work at all?
The text was updated successfully, but these errors were encountered: