-
Notifications
You must be signed in to change notification settings - Fork 3.6k
HHH-11866 fix CustomEntityDirtinessStrategy#resetDirty is not called after entity initialization #10218
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
base: main
Are you sure you want to change the base?
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 @peter1123581321, your changes look good. Left a few minor comments
hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
Outdated
Show resolved
Hide resolved
hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
Outdated
Show resolved
Hide resolved
hibernate-core/src/test/java/org/hibernate/orm/test/dirtiness/HHH11866Test.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.
Please move the call to resetDirty()
to the new method EntityEntryImpl.postLoad()
.
Then this should be fine.
1fdaacb
to
a6ef23c
Compare
hibernate-core/src/main/java/org/hibernate/engine/internal/EntityEntryImpl.java
Outdated
Show resolved
Hide resolved
hibernate-core/src/main/java/org/hibernate/engine/internal/EntityEntryImpl.java
Outdated
Show resolved
Hide resolved
8b1c8ce
to
cef2a17
Compare
hibernate-core/src/main/java/org/hibernate/engine/internal/EntityEntryImpl.java
Outdated
Show resolved
Hide resolved
Thanks for your pull request! This pull request appears to follow the contribution rules. › This message was automatically generated. |
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.
@peter1123581321 this looks good, please squash everything to a single commit.
Since the fix depends on #10226 we won't be back-porting it.
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, @peter1123581321
…after entity initialization
780f511
to
a42e181
Compare
Using a CustomEntityDirtinessStrategy leads to entities marked as dirty after they have been first loaded.
Consequently, calling flush immediately afterwards leads to an update, although the entity has not been changed.
The fix added a call of CustomEntityDirtinessStrategy#resetDirty in AbstractEntityPersister#afterInitialize.
The fix also needed a change of two assertions in CustomDirtinessStrategyTest, but they are ok.
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-11866