Skip to content
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

HHH-18992 - Locking does not work with multiLoad #9681

Merged
merged 4 commits into from
Feb 6, 2025

Conversation

jrenaat
Copy link
Member

@jrenaat jrenaat commented Jan 28, 2025


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.


https://hibernate.atlassian.net/browse/HHH-18992

@jrenaat jrenaat requested review from gavinking and mbladel January 28, 2025 22:51
Copy link
Member

@gavinking gavinking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @jrenaat!

I have left some very minor suggestions.

But on the test side of things, I have this additional feedback:

  1. This bug also affects Session.findMultiple() when passed a lock mode as a FindOption, so we should test that too, since that's what we now recommend.
  2. If you look at my commits on this issue, the bug also affected load by natural id, so we should test that too.
  3. I know that this is harder to test, but we really should test that the lock mode is actually affecting the generated SQL.

Copy link
Member

@mbladel mbladel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few minor comments, but the fix looks great!

Though not strictly necessary, it would be nice if you could also apply the correct code-style to the test class.

Edit: looks like @gavinking beat me to this, I agree it would be great to add more tests and perhaps the fixes could be similar.

@jrenaat jrenaat mentioned this pull request Jan 30, 2025
@jrenaat jrenaat force-pushed the HHH-18992_lockmode branch 3 times, most recently from e46b1f7 to b5dcde4 Compare February 5, 2025 14:46
wanderer2097 and others added 4 commits February 5, 2025 22:21
- added an @AfterEach tearDown method
- added tests also for findMultiple and byMultipleNaturalId
- corrected the tests that use optimistic/optimistic_force_increment
  (they should use a versioned entity)
- add statement inspection where applicable

Signed-off-by: Jan Schatteman <[email protected]>
… by default to false, as otherwise an UnsupportedOperationException would be thrown by the MultiNaturalIdLoaderInPredicate

Signed-off-by: Jan Schatteman <[email protected]>
Signed-off-by: Jan Schatteman <[email protected]>
@jrenaat jrenaat force-pushed the HHH-18992_lockmode branch from b5dcde4 to 8e575c4 Compare February 5, 2025 21:21
@jrenaat jrenaat requested review from mbladel and gavinking February 5, 2025 22:13
Copy link
Member

@gavinking gavinking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@jrenaat jrenaat merged commit ca1d66f into hibernate:main Feb 6, 2025
26 checks passed
@@ -34,7 +34,7 @@ public class NaturalIdMultiLoadAccessStandard<T> implements NaturalIdMultiLoadAc

private Integer batchSize;
private boolean returnOfDeletedEntitiesEnabled;
private boolean orderedReturnEnabled = true;
private boolean orderedReturnEnabled = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this default changed? The jdoc of NaturalIdMultiLoadAccess#enableOrderedReturn says:

By default, the returned list is ordered and the positions of the
entities correspond to the positions of their ids. [...]

This seems to break that assumption, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants