-
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-13705 Enhancement as Proxy with inline dirty checking - flush of an @ManyToOne with an Embedded value having not null properties causes PropertyValueException #3092
Conversation
HHH-13705 Add test for issue
@manytoone with an Embedded value having not null properties causes PropertyValueException
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.
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.
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.
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(); |
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.
But didn't you just instantiate the entity?
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.
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.
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.
probably a better approach is to add to the enhanced class the ability to reset the tracker on exit of the constructor method
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.
No, you explained it.. that's reasonable
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.
An alternative (same net effect) would be to disable dirty tracking during construction
rebased and merged upstream. Thanks @gbadner and @sebersole for the reviews |
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 associatedClient
results having fields that are marked as dirty in the dirtyness tracker, this happens when theClient
is instantiated.For
User
the fields that are marked as dirty in the dirtyness tracker are cleared whenPojoEntityTuplizer#afterInitialize
calls( (SelfDirtinessTracker) entity ).$$_hibernate_clearDirtyAttributes();
this causes an update during the flush.
I hope my explanation is not too messy ;)