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
set / clear and addAll does not work on a orphanRemoval=true #3213
Comments
This is an issue with List and how that is working specifically when orphan removal is used ( "Modify Listening" is enabled ). Being a List the add() and remove() default to work via instance rather that Next step is to organise the existing tests and add the new failing ones (that are expecting/needed |
It turns out in Hibernate assigning a list with orphan removal in a setter is actively blocked (Hibernate throws an exception). That is logical because you need a List-implementation with orphan logic, so the original implementation of our setter simply is not okay. But the clear/addAll should work. As with the other issues, we will revisit this when we are at the latest EBean version. (We've just started using 12 into our code base.) |
I've reviewed the tests and the current behaviour of Looking at the workaround code I think what is being asked for is for the The clear() + addAll() really must work as it does - I don't see much of a case for addAll there to do something like "restore" elements that were previously cleared. I think the request here ends up as desiring List.retainAll() + List.addAll() to perform the same operation as the workaround code - effectively a change in behaviour for |
We're rolling out J11 in phases to production ATM. It should be done in about 2 weeks. Then the first step is to update to EBean 13 and we'll pick up these issues again. And then we can do testing of any changes. |
We have the following collection:
If a setter simply assigns the collection under EBean 12:
Then we observe in some scenario's that existing expenseDistances are removed and only newly added are persisted. So we changed the implementation for collections with orhpanRemoval to:
This results both under 7 and 12 in the behaviour that if a new collection with exactly the same entities is set (coming from a REST API), all expenseDistances are deleted. Somehow the orphan deletes are not negated by the new entities. Unoptimised we would at least have expected deletes followed by inserts.
The following does not work either:
This code below seems to work correctly:
The text was updated successfully, but these errors were encountered: