HHH-7304 bugfix proposal

This commit is contained in:
Guenther Demetz 2012-05-09 16:42:39 +02:00 committed by Brett Meyer
parent f58557a567
commit a407665819
3 changed files with 17 additions and 3 deletions

View File

@ -72,7 +72,9 @@ public abstract class AbstractEntityInsertAction extends EntityAction {
this.isExecuted = false;
this.areTransientReferencesNullified = false;
handleNaturalIdPreSaveNotifications();
if (id != null) {
handleNaturalIdPreSaveNotifications();
}
}
/**
@ -193,7 +195,17 @@ public abstract class AbstractEntityInsertAction extends EntityAction {
/**
* Handle sending notifications needed for natural-id after saving
*/
protected void handleNaturalIdPostSaveNotifications() {
public void handleNaturalIdPostSaveNotifications(Serializable id) {
if (isEarlyInsert()) {
// with early insert, we still need to add a local (transactional) natural id cross-reference
getSession().getPersistenceContext().getNaturalIdHelper().manageLocalNaturalIdCrossReference(
getPersister(),
id,
state,
null,
CachedNaturalIdValueSource.INSERT
);
}
// after save, we need to manage the shared cache entries
getSession().getPersistenceContext().getNaturalIdHelper().manageSharedNaturalIdCrossReference(
getPersister(),

View File

@ -123,7 +123,7 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
}
}
handleNaturalIdPostSaveNotifications();
handleNaturalIdPostSaveNotifications(id);
postInsert();

View File

@ -298,6 +298,8 @@ public abstract class AbstractSaveEventListener extends AbstractReassociateEvent
insert.getClass().getName() );
}
id = ( ( EntityIdentityInsertAction ) insert ).getGeneratedId();
insert.handleNaturalIdPostSaveNotifications(id);
}
markInterceptorDirty( entity, persister, source );