Skip to content

Commit

Permalink
Fix ManyToOneType#isModified() causing unnecessary update execution
Browse files Browse the repository at this point in the history
  • Loading branch information
dreab8 committed Jul 8, 2021
1 parent 547e247 commit 0831823
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Expand Up @@ -189,15 +189,18 @@ public boolean isModified(
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
Expand Down
Expand Up @@ -121,10 +121,8 @@ public boolean isDirty(Object old, Object current, SharedSessionContractImplemen
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
Expand Down

0 comments on commit 0831823

Please sign in to comment.