-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Conversation
There was a problem hiding this 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:
- This bug also affects
Session.findMultiple()
when passed a lock mode as aFindOption
, so we should test that too, since that's what we now recommend. - If you look at my commits on this issue, the bug also affected load by natural id, so we should test that too.
- I know that this is harder to test, but we really should test that the lock mode is actually affecting the generated SQL.
...nate-core/src/main/java/org/hibernate/loader/ast/internal/MultiIdEntityLoaderArrayParam.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/hibernate/loader/ast/internal/ExecutionContextWithSubselectFetchHandler.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/hibernate/loader/ast/internal/ExecutionContextWithSubselectFetchHandler.java
Outdated
Show resolved
Hide resolved
hibernate-core/src/main/java/org/hibernate/loader/ast/internal/MultiIdEntityLoaderStandard.java
Outdated
Show resolved
Hide resolved
hibernate-core/src/test/java/org/hibernate/orm/test/loading/multiLoad/MultiLoadLockingTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
...c/main/java/org/hibernate/loader/ast/internal/ExecutionContextWithSubselectFetchHandler.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/hibernate/loader/ast/internal/ExecutionContextWithSubselectFetchHandler.java
Outdated
Show resolved
Hide resolved
...nate-core/src/main/java/org/hibernate/loader/ast/internal/MultiIdEntityLoaderArrayParam.java
Outdated
Show resolved
Hide resolved
hibernate-core/src/main/java/org/hibernate/loader/ast/internal/MultiIdEntityLoaderStandard.java
Outdated
Show resolved
Hide resolved
e46b1f7
to
b5dcde4
Compare
- 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]>
b5dcde4
to
8e575c4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@@ -34,7 +34,7 @@ public class NaturalIdMultiLoadAccessStandard<T> implements NaturalIdMultiLoadAc | |||
|
|||
private Integer batchSize; | |||
private boolean returnOfDeletedEntitiesEnabled; | |||
private boolean orderedReturnEnabled = true; | |||
private boolean orderedReturnEnabled = false; |
There was a problem hiding this comment.
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?
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