HHH-3910 - custom dirty flag tracking

This commit is contained in:
Steve Ebersole 2012-01-25 12:38:57 -06:00
parent 34c2fa4409
commit 72e382b045
3 changed files with 15 additions and 17 deletions

View File

@ -33,8 +33,12 @@ import org.hibernate.engine.spi.SessionImplementor;
/**
* Helper class for dealing with enhanced entity classes.
*
* These operations are expensive. When under a SessionFactory, try and use (or guard with)
* {@link org.hibernate.service.instrumentation.spi.InstrumentationService#isInstrumented}
* These operations are expensive. They are only meant to be used when code does not have access to a
* SessionFactory (namely from the instrumentation tasks). When code has access to a SessionFactory,
* {@link org.hibernate.bytecode.spi.EntityInstrumentationMetadata} should be used instead to query the
* instrumentation state. EntityInstrumentationMetadata is accessed from the
* {@link org.hibernate.persister.entity.EntityPersister} via the
* {@link org.hibernate.persister.entity.EntityPersister#getInstrumentationMetadata()} method.
*
* @author Steve Ebersole
*/
@ -96,20 +100,6 @@ public class FieldInterceptionHelper {
return interceptor;
}
public static void clearDirty(Object entity) {
FieldInterceptor interceptor = extractFieldInterceptor( entity );
if ( interceptor != null ) {
interceptor.clearDirty();
}
}
public static void markDirty(Object entity) {
FieldInterceptor interceptor = extractFieldInterceptor( entity );
if ( interceptor != null ) {
interceptor.dirty();
}
}
private static interface Delegate {
public boolean isInstrumented(Class classToCheck);
public FieldInterceptor extractInterceptor(Object entity);

View File

@ -234,6 +234,10 @@ public final class EntityEntry implements Serializable {
if ( interceptor != null ) {
interceptor.clearDirty();
}
persistenceContext.getSession()
.getFactory()
.getCustomEntityDirtinessStrategy()
.resetDirty( entity, (Session) persistenceContext.getSession() );
}
notifyLoadedStateUpdated();

View File

@ -249,6 +249,10 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
.extractInterceptor( event.getEntity() )
.clearDirty();
}
event.getSession()
.getFactory()
.getCustomEntityDirtinessStrategy()
.resetDirty( event.getEntity(), event.getSession() );
return false;
}
}