HHH-7829 NullPointerException when manually flushing One-To-One

relationship with orphan removal
This commit is contained in:
Brett Meyer 2013-02-01 12:59:39 -05:00
parent 470c7432c4
commit 76c14b1697
1 changed files with 10 additions and 6 deletions

View File

@ -256,13 +256,17 @@ public final class Cascade {
final EntityEntry valueEntry = eventSource
.getPersistenceContext().getEntry(
loadedValue );
final String entityName = valueEntry.getPersister().getEntityName();
if ( LOG.isTraceEnabled() ) {
final Serializable id = valueEntry.getPersister().getIdentifier( loadedValue, eventSource );
final String description = MessageHelper.infoString( entityName, id );
LOG.tracev( "Deleting orphaned entity instance: {0}", description );
// Need to check this in case the context has
// already been flushed. See HHH-7829.
if ( valueEntry != null ) {
final String entityName = valueEntry.getPersister().getEntityName();
if ( LOG.isTraceEnabled() ) {
final Serializable id = valueEntry.getPersister().getIdentifier( loadedValue, eventSource );
final String description = MessageHelper.infoString( entityName, id );
LOG.tracev( "Deleting orphaned entity instance: {0}", description );
}
eventSource.delete( entityName, loadedValue, false, new HashSet() );
}
eventSource.delete( entityName, loadedValue, false, new HashSet() );
}
}
}