HHH-8374: Treat an entity wrapped by hibernate proxy equals a raw entity

This commit is contained in:
sndyuk 2014-02-28 20:06:01 +09:00 committed by Brett Meyer
parent 7f2eb1c525
commit 05c078e459
1 changed files with 8 additions and 0 deletions

View File

@ -60,6 +60,8 @@ import org.hibernate.cache.CacheException;
import org.hibernate.engine.internal.NonNullableTransientDependencies;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.proxy.LazyInitializer;
import org.hibernate.type.Type;
/**
@ -614,6 +616,12 @@ public class ActionQueue {
}
public void unScheduleDeletion(EntityEntry entry, Object rescuedEntity) {
if ( rescuedEntity instanceof HibernateProxy ) {
LazyInitializer initializer = ( ( HibernateProxy ) rescuedEntity ).getHibernateLazyInitializer();
if ( !initializer.isUninitialized() ) {
rescuedEntity = initializer.getImplementation( session );
}
}
for ( int i = 0; i < deletions.size(); i++ ) {
EntityDeleteAction action = deletions.get( i );
if ( action.getInstance() == rescuedEntity ) {