-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Eliminate unnecessary merge() if entity is non-versioned #3402
base: main
Are you sure you want to change the base?
Conversation
Can you please provide additional integration tests for the cases of optimistic locking failures and removal of an entity that contains modifications? |
It's nothing related to optimistic locking but |
The PR as it stands right now, is not acceptable. It will not throw an It is not about avoiding optimistic locking exceptions. |
I get your point now, that's not covered by existing tests, I will try. |
I've updated this PR, I suggest not to squash commits, at least the first commit should be kept as it is. @schauder |
Thanks for the additional test. There is still one scenario to investigate though. What happens in the old and new version of the code when the entity (without optimistic locking) to be deleted contains changes, i.e. it is dirty. The previous version might actually flush those changes, potentially triggering life cycle events, triggers and validations. |
It's weird that flush changes before deletion, IMO we should eliminate those side effects for versioned entity too, by comparing versions between |
I'm very much against changing anything about the observed behaviour in this. |
OK, should I update commits to only keep the first one? |
I'm not sure I understand the intention with this one. I honestly aren't sure how exactly the old and the proposed new version of the code behave. There is no blame in failing to optimise this method. At least I hope so because I tried myself before and failed miserably :o) |
I don't understand integration tests that you said, the commit ac3f819 added test to guard current behavior that deleting stale detached entity should cause optimistic lock failure. |
But it does not test what happens, when you delete a managed dirty entity. |
JPA will guarantee it raise |
In this scenario the interesting case is not for versioned entities, but for unversioned. There is a risk that they get flushed to the database triggering life cycle events, database triggers and database constraints, while the new version won't |
You mentioned it already, I agree that but I think the risk is tiny. |
No, we need a test mitigating that risk. |
52ee55f
to
61e6d36
Compare
Fix GH-3401