}
}
private boolean scheduleUpdate(final FlushEntityEvent event) {
final EntityEntry entry = event.getEntityEntry();
final EventSource session = event.getSession();
final Object entity = event.getEntity();
final Status status = entry.getStatus();
final EntityMode entityMode = session.getEntityMode();
final EntityPersister persister = entry.getPersister();
final Object[] values = event.getPropertyValues();
if ( log.isTraceEnabled() ) {
if ( status == Status.DELETED ) {
log.trace(
"Updating deleted entity: " +
MessageHelper.infoString( persister, entry.getId(), session.getFactory() )
);
}
else {
log.trace(
"Updating entity: " +
MessageHelper.infoString( persister, entry.getId(), session.getFactory() )
);
}
}
final boolean intercepted;
if ( !entry.isBeingReplicated() ) {
// give the Interceptor a chance to process property values, if the properties
// were modified by the Interceptor, we need to set them back to the object
intercepted = handleInterception( event );
}
else {
intercepted = false;
}
validate( entity, persister, status, entityMode );
// increment the version number (if necessary)
final Object nextVersion = getNextVersion(event);
// if it was dirtied by a collection only
int[] dirtyProperties = event.getDirtyProperties();
if ( event.isDirtyCheckPossible() && dirtyProperties == null ) {
if ( ! intercepted && !event.hasDirtyCollection() ) {
throw new AssertionFailure( "dirty, but no dirty properties" );
}
dirtyProperties = ArrayHelper.EMPTY_INT_ARRAY;
}
// check nullability but do not perform command execute
// we'll use scheduled updates for that.
new Nullability(session).checkNullability( values, persister, true );
// schedule the update
// note that we intentionally do _not_ pass in currentPersistentState!
session.getActionQueue().addAction(
new EntityUpdateAction(
entry.getId(),
values,
dirtyProperties,
event.hasDirtyCollection(),
entry.getLoadedState(),
entry.getVersion(),
nextVersion,
entity,
entry.getRowId(),
persister,
session
)
);