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-13705 Enhancement as Proxy with inline dirty checking - flush of an @ManyToOne with an Embedded value having not null properties causes PropertyValueException #3092

Closed
wants to merge 2 commits into from

Conversation

dreab8
Copy link
Member

@dreab8 dreab8 commented Nov 5, 2019

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

An example is https://github.com/hibernate/hibernate-orm/compare/master...dreab8:HHH-13705?expand=1#diff-3e7d7f46b89f78dfa756348772394254

when the User is loaded the associated Client results having fields that are marked as dirty in the dirtyness tracker, this happens when the Client is instantiated.

For User the fields that are marked as dirty in the dirtyness tracker are cleared when PojoEntityTuplizer#afterInitialize calls ( (SelfDirtinessTracker) entity ).$$_hibernate_clearDirtyAttributes();

this causes an update during the flush.

I hope my explanation is not too messy ;)

HHH-13705 Add test for issue
@manytoone with an Embedded value having not null properties causes PropertyValueException
@dreab8 dreab8 requested review from sebersole and gbadner November 5, 2019 17:13
Copy link
Contributor

@gbadner gbadner left a comment

Choose a reason for hiding this comment

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

I am not absolutely sure about this, but it looks correct to me.

I think it would be best for @sebersole to take a look.

Copy link
Member

@sebersole sebersole left a comment

Choose a reason for hiding this comment

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

I'm not understanding - we can talk about it tomorrow if that works for you


// clear the fields that are marked as dirty in the dirtyness tracker
if ( entity instanceof SelfDirtinessTracker ) {
( (SelfDirtinessTracker) entity ).$$_hibernate_clearDirtyAttributes();
Copy link
Member

Choose a reason for hiding this comment

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

But didn't you just instantiate the entity?

Copy link
Member Author

@dreab8 dreab8 Nov 12, 2019

Choose a reason for hiding this comment

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

what I noticed is that when

@Entity(name = "Client")
public static class Client {
        ....
	@Embedded
	private Log log = new Log();
}

is instantiated, because the field log has an assigned initial value new Log() a call of $$_hibernate_write_log and then of $$_hibernate_trackChange is triggered so the newly instantiated entity results dirty.

This happens with all the fields that have an assigned initial value.

Copy link
Member Author

Choose a reason for hiding this comment

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

probably a better approach is to add to the enhanced class the ability to reset the tracker on exit of the constructor method

Copy link
Member

Choose a reason for hiding this comment

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

No, you explained it.. that's reasonable

Copy link
Member

Choose a reason for hiding this comment

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

An alternative (same net effect) would be to disable dirty tracking during construction

@dreab8
Copy link
Member Author

dreab8 commented Nov 14, 2019

rebased and merged upstream.

Thanks @gbadner and @sebersole for the reviews

@dreab8 dreab8 closed this Nov 14, 2019
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