HHH-7304 bugfix proposal
This commit is contained in:
parent
160547ecd1
commit
213ce0d060
|
@ -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(),
|
||||
|
|
|
@ -123,7 +123,7 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
|
|||
}
|
||||
}
|
||||
|
||||
handleNaturalIdPostSaveNotifications();
|
||||
handleNaturalIdPostSaveNotifications(id);
|
||||
|
||||
postInsert();
|
||||
|
||||
|
|
|
@ -298,6 +298,8 @@ public abstract class AbstractSaveEventListener extends AbstractReassociateEvent
|
|||
insert.getClass().getName() );
|
||||
}
|
||||
id = ( ( EntityIdentityInsertAction ) insert ).getGeneratedId();
|
||||
|
||||
insert.handleNaturalIdPostSaveNotifications(id);
|
||||
}
|
||||
|
||||
markInterceptorDirty( entity, persister, source );
|
||||
|
|
Loading…
Reference in New Issue