ManyToOneType.isModified

Description

public class ManyToOneType extends EntityType {
.....
public boolean isModified(
Object old,
Object current,
boolean[] checkable,
SessionImplementor session) throws HibernateException {
if ( current == null ) {
return old!=null;
}
if ( old == null ) {
// we already know current is not null...
return true;
}
// the ids are fully resolved, so compare them with isDirty(), not isModified()
return getIdentifierOrUniqueKeyType( session.getFactory() )
.isDirty( old, getIdentifier( current, session ), session );
}
....
}

When using findModified method on the EntityPersister all no null many-to-one properties is returned as modified because the isDirty is called with old that is the object instance (ie. not the identifier) and for current the identifier is resolved. Last line should be

return getIdentifierOrUniqueKeyType( session.getFactory() )
.isDirty( getIdentifier( old, session ), getIdentifier( current, session ), session );

Environment

None

Activity

Show:
Brett Meyer
April 21, 2014, 1:50 PM
Edited

Sorry guys, had to revert and re-open this. I should have looked more closely at the fix. This causes multiple failures. Example: SaveOrUpdateTest#testSaveOrUpdateTree. Stack:

In that stack, #isModified is handed the entity for "current", and only the already-resolved identifier for "old".

Guillaume Smet
April 21, 2014, 2:42 PM

Hi Brett,

Back from vacation. I'll look deeper into this one. I'll check that the use case is fixed. If not I'll see how to fix it and if it already fixed, I think we should at least make the code clearer: the variable name should be oldIdentifier, not old.

Will work on it this week.

Steve Ebersole
October 27, 2015, 6:55 PM

This bug report does not indicate that the reported issue affects version 5.x. Versions prior to 5.x are no longer maintained. It would be a great help to the Hibernate team and community for someone to verify that the reported issue still affects version 5.x. If so, please add the 5.x version that you verified with to the list of affected-versions and attach the (preferably SSCCE) test case you used to do the verification to the report; from there the issues will be looked at during our triage meetings.

For details, see http://in.relation.to/2015/10/27/great-jira-cleanup-2015/

Steve Ebersole
October 27, 2015, 7:17 PM

This bug report does not indicate that the reported issue affects version 5.x. Versions prior to 5.x are no longer maintained. It would be a great help to the Hibernate team and community for someone to verify that the reported issue still affects version 5.x. If so, please add the 5.x version that you verified with to the list of affected-versions and attach the (preferably SSCCE) test case you used to do the verification to the report; from there the issues will be looked at during our triage meetings.

For details, see http://in.relation.to/2015/10/27/great-jira-cleanup-2015/

Steve Ebersole
October 28, 2015, 3:26 AM

As part of verifying that this issue affects 5.0, please just set the "Affects version". Leave the "verify-affects-5.0" label and leave the issue in "Awaiting Response" status; these are critical for us to be able to track these verifications and triage them. Thanks.

Assignee

Unassigned

Reporter

Riccardo Mirasola

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure