Dirty check for CustomEntityDirtynessStrategy gets bypassed with current implemenation
--------------------------------------------------------------------------------------
Key: HHH-7292
URL:
https://hibernate.onjira.com/browse/HHH-7292
Project: Hibernate ORM
Issue Type: Improvement
Components: core
Affects Versions: 4.1.2
Environment: N/A
Reporter: Shawn Clowater
When initially testing the new functionality around the CustomEntityDirtynessStrategy it
seemed to work pretty well to be able to identify what properties are dirty in the event
that the entity is dirty. However, I was noticing that the default checking was kicking
in if my strategy was returning null for the dirty properties.
I believe the problem lies in the dirty check in the EntityEntry class
{code}
public boolean requiresDirtyCheck(Object entity) {
return isModifiableEntity()
&& ( getPersister().hasMutableProperties() || ! isUnequivocallyNonDirty(
entity ) );
}
@SuppressWarnings( {"SimplifiableIfStatement"})
private boolean isUnequivocallyNonDirty(Object entity) {
if ( getPersister().getInstrumentationMetadata().isInstrumented() ) {
// the entity must be instrumented (otherwise we cant check dirty flag) and the dirty
flag is false
return ! getPersister().getInstrumentationMetadata().extractInterceptor( entity
).isDirty();
}
final CustomEntityDirtinessStrategy customEntityDirtinessStrategy =
persistenceContext.getSession().getFactory().getCustomEntityDirtinessStrategy();
if ( customEntityDirtinessStrategy.canDirtyCheck( entity, getPersister(), (Session)
persistenceContext.getSession() ) ) {
return ! customEntityDirtinessStrategy.isDirty( entity, getPersister(), (Session)
persistenceContext.getSession() );
}
return false;
}
{code}
Basically, any entity that has mutable properties will effectively end up bypassing the
custom dirty checking.
The proposed solution is to do the custom checking initially and then default to the
hasMutableProperties as a fallback in order to perform the default checking.
I'll hopefully get some cycles for this prior to 4.1.4
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira