-
-
Notifications
You must be signed in to change notification settings - Fork 260
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
Cascading update isn't propagated - use of merge() vs "stateless update" #1656
Comments
A way to get the test to pass is to use That is: MergeOptions options = new MergeOptionsBuilder()
.addPath("foo")
.addPath("foo.children")
.build();
DB.merge(deserialized, options); In short, Merge can be used to any depth because we are explicitly telling Ebean the paths that should be included in the 'merge / update'. In the merge code above we explicitly specify the paths of So to me you have hit that limit of where Now I can understand that with this model there is the "orphanRemoval=true" on those paths so that implies that In the meantime you should consider using merge() instead. Does that make sense? |
@viluon did the above comment make sense? Thanks, Rob. |
@viluon ... I'll close this for now. I am assuming you are using |
@rbygrave thanks for the workaround, but a workaround isn't a fix. I would expect a stateless update to work with Note that a fix for this and another issue was proposed in #1403, but was rejected due to refactoring work. The provided unit test shows that a proper solution never made it to |
@rbygrave could you please reopen this issue to reflect the state of the bug? |
That doesn't make sense to me. You will need to expand on that ... (are you stuck on your own fork?)
Well that PR was closed with agreement that the issue was resolved by other changes. That PR didn't contain ANY failing test case. If that PR contained "a fix" then you could create a PR with the failing test and the associated fix and I could review that - no problem with that - why don't you do that?
I believe it is more complex than that. More specifically the ability to differentiate between an empty collection for non-cascading and an empty collection that is "remove all as orphans". We have to be pretty careful with the behaviour here. I believe the interesting aspect here is the orphanRemoval=true setting on the relationships which might be enough to imply that a stateless update can be "aggressive" wrt cascading collections. Another option would be to use MergeOptions/MergeOptionsBuilder to be explicit on the paths to cascade (rather than being implicit).
The other workaround would be to perform a stateless update on I'll re-open but not sure when I'll get to look at it. I would be good if you can clarify the points raised above. Cheers, Rob. |
Closing. No feed back, expecting people to use merge() when appropriate. |
I think the disadvantages of using What's even worse is a situation where the programmer doesn't realise that a stateless update is not enough, this obscure Ebean bug isn't caught in testing and makes its way to production, where it causes serious trouble and requires a manual revert of the database to a previous state. Using To summarise, using I would consider this bug in violation of the guarantees promised by the Java Persistence API, but I am unsure of JPA's exact phrasings. I have provided a test case showcasing the behaviour. If you insist on closing the issue, you are saying that this is in fact not a bug and that the test should never have passed in the first place. Therefore, a feature of Ebean 11.7.2 has been deprecated later on for no apparent reason. This is also in violation of semantic versioning, which requires API removals to bump the major version number, but I'm not sure if Ebean aims to follow semver or not. If you keep this issue open, you'll allow people to discover the bug and perhaps implement patches to fix it. It is a way of admitting that this is a real problem in search of a solution. |
Ok, lets reopen. |
Refer to #1824 ... which is the same issue. PR pending. This is considered as a breaking change, removing the deleteMissingChildren parameter for stateless updates in favour of always honouring orphanRemoval. |
…ption, instead always use orphanRemoval
…ption, instead always use orphanRemoval Adjust test that doesn't have orphanRemoval (so missing children are not removed here now)
I believe we've come across a bug with
EbeanServer.update()
. In the provided test case, an update isn't propagated to linked entities (despiteCascadeType.ALL
). This happens on Ebeans 11.22.10.Expected behavior
The provided unit test should pass.
Actual behavior
The update doesn't touch a list of entities deeper within the hierarchy.
Steps to reproduce
This gist contains a unit test showcasing the issue. The unit test fails with the following output:
The text was updated successfully, but these errors were encountered: