Fix ManyToOneType#isModified() causing unnecessary update execution

This commit is contained in:
Andrea Boriero 2021-07-02 19:00:20 +02:00
parent 547e247bb6
commit 0831823b27
2 changed files with 7 additions and 6 deletions

View File

@ -189,15 +189,18 @@ public class ManyToOneType extends EntityType {
boolean[] checkable,
SharedSessionContractImplementor session) throws HibernateException {
if ( current == null ) {
return old!=null;
return old != null;
}
if ( old == null ) {
// we already know current is not null...
return true;
}
assert current.getClass().isAssignableFrom( old.getClass() );
// the ids are fully resolved, so compare them with isDirty(), not isModified()
return getIdentifierOrUniqueKeyType( session.getFactory() )
.isDirty( old, getIdentifier( current, session ), session );
.isDirty( getIdentifier( old, session ), getIdentifier( current, session ), session );
}
@Override

View File

@ -121,10 +121,8 @@ public class OneToOneType extends EntityType {
return false;
}
Object oldid = getIdentifier( old, session );
Object newid = getIdentifier( current, session );
return getIdentifierType( session ).isDirty( oldid, newid, session );
return getIdentifierType( session )
.isDirty( getIdentifier( old, session ), getIdentifier( current, session ), session );
}
@Override