HHH-15986 Eager Bidirectional association, initializing an HibernateProxy should associate to the circular association the HibernateProxy itself
This commit is contained in:
parent
e0ff430936
commit
303da7fca8
|
@ -155,8 +155,7 @@ public class CircularBiDirectionalFetchImpl implements BiDirectionalFetch {
|
||||||
final EntityPersister entityPersister = (EntityPersister) fetchable.asAttributeMapping().getMappedType();
|
final EntityPersister entityPersister = (EntityPersister) fetchable.asAttributeMapping().getMappedType();
|
||||||
final CollectionKey collectionKey = circ.resolveCollectionKey( rowProcessingState );
|
final CollectionKey collectionKey = circ.resolveCollectionKey( rowProcessingState );
|
||||||
final Object key = collectionKey.getKey();
|
final Object key = collectionKey.getKey();
|
||||||
final SharedSessionContractImplementor session = rowProcessingState.getJdbcValuesSourceProcessingState()
|
final SharedSessionContractImplementor session = rowProcessingState.getSession();
|
||||||
.getSession();
|
|
||||||
final PersistenceContext persistenceContext = session.getPersistenceContext();
|
final PersistenceContext persistenceContext = session.getPersistenceContext();
|
||||||
if ( fetchable.getReferencedPropertyName() != null ) {
|
if ( fetchable.getReferencedPropertyName() != null ) {
|
||||||
return loadByUniqueKey( entityPersister, key, session, persistenceContext );
|
return loadByUniqueKey( entityPersister, key, session, persistenceContext );
|
||||||
|
@ -182,12 +181,15 @@ public class CircularBiDirectionalFetchImpl implements BiDirectionalFetch {
|
||||||
final Object initializedInstance = initializer.getInitializedInstance();
|
final Object initializedInstance = initializer.getInitializedInstance();
|
||||||
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( initializedInstance );
|
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( initializedInstance );
|
||||||
if ( lazyInitializer != null ) {
|
if ( lazyInitializer != null ) {
|
||||||
if ( initializedInstance.getClass().isAssignableFrom( javaType.getJavaTypeClass() ) ) {
|
final Class<?> concreteProxyClass = initializer.getConcreteDescriptor().getConcreteProxyClass();
|
||||||
|
if ( concreteProxyClass.isInstance( initializedInstance ) ) {
|
||||||
return initializedInstance;
|
return initializedInstance;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
initializer.initializeInstance( rowProcessingState );
|
initializer.initializeInstance( rowProcessingState );
|
||||||
return lazyInitializer.getImplementation();
|
return lazyInitializer.getImplementation();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return initializedInstance;
|
return initializedInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue