Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

peter1123581321
Copy link
Contributor

@peter1123581321 peter1123581321 commented May 24, 2025

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

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.

Thanks @peter1123581321, your changes look good. Left a few minor comments

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.

Please move the call to resetDirty() to the new method EntityEntryImpl.postLoad().

Then this should be fine.

@peter1123581321 peter1123581321 marked this pull request as draft May 27, 2025 06:45
@peter1123581321 peter1123581321 force-pushed the HHH-11866 branch 2 times, most recently from 8b1c8ce to cef2a17 Compare May 27, 2025 12:22
@peter1123581321 peter1123581321 marked this pull request as ready for review May 27, 2025 12:25
@hibernate-github-bot
Copy link

hibernate-github-bot bot commented May 27, 2025

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

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.

@peter1123581321 this looks good, please squash everything to a single commit.

Since the fix depends on #10226 we won't be back-porting it.

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.

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.

3 participants