HHH-7304 bugfix proposal

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

View File

@ -72,8 +72,10 @@ public abstract class AbstractEntityInsertAction extends EntityAction {
this.isExecuted = false;
this.areTransientReferencesNullified = false;
if (id != null) {
handleNaturalIdPreSaveNotifications();
}
}
/**
* Returns the entity state.
@ -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 );