HHH-11459 - Do not fetch a collection on cascade, resolve it instead

This commit is contained in:
barreiro 2017-03-21 00:46:38 +00:00 committed by Gail Badner
parent 2779ebd8f0
commit 41bd06266d
1 changed files with 8 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import java.util.HashSet;
import java.util.Iterator;
import org.hibernate.HibernateException;
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.spi.CascadeStyle;
@ -94,8 +95,13 @@ public final class Cascade {
// For bytecode enhanced entities, need to fetch the attribute
if ( hasUninitializedLazyProperties && persister.getPropertyLaziness()[i] && action.performOnLazyProperty() ) {
LazyAttributeLoadingInterceptor interceptor = persister.getInstrumentationMetadata().extractInterceptor( parent );
child = interceptor.fetchAttribute( parent, propertyName );
if ( types[i].isCollectionType() ) {
child = types[i].resolve( LazyPropertyInitializer.UNFETCHED_PROPERTY, eventSource, parent );
}
else {
LazyAttributeLoadingInterceptor interceptor = persister.getInstrumentationMetadata().extractInterceptor( parent );
child = interceptor.fetchAttribute( parent, propertyName );
}
}
else {
child = persister.getPropertyValue( parent, i );