HHH-10989 - Always resolve CollectionType on load so that unfetched collections have a reference stored in StatefulPersistentContext
HHH-10989 : Shorten test table names
This commit is contained in:
parent
077ebbc04f
commit
55f7f71e04
|
@ -34,7 +34,6 @@ import org.hibernate.persister.entity.EntityPersister;
|
|||
import org.hibernate.pretty.MessageHelper;
|
||||
import org.hibernate.property.access.internal.PropertyAccessStrategyBackRefImpl;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
import org.hibernate.type.CollectionType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.TypeHelper;
|
||||
|
||||
|
@ -148,15 +147,24 @@ public final class TwoPhaseLoad {
|
|||
final Type[] types = persister.getPropertyTypes();
|
||||
for ( int i = 0; i < hydratedState.length; i++ ) {
|
||||
final Object value = hydratedState[i];
|
||||
if ( value!=LazyPropertyInitializer.UNFETCHED_PROPERTY && value!= PropertyAccessStrategyBackRefImpl.UNKNOWN ) {
|
||||
hydratedState[i] = types[i].resolve( value, session, entity );
|
||||
}
|
||||
else if ( types[i].isCollectionType() ) {
|
||||
// HHH-10989 Even if not fetched, resolve a collection so that a CollectionReference is added to StatefulPersistentContext
|
||||
// No assignment to the hydratedState, that would trigger the load of the collection (below, on setPropertyValues)
|
||||
if ( value == LazyPropertyInitializer.UNFETCHED_PROPERTY ) {
|
||||
// IMPLEMENTATION NOTE: This is a lazy property on a bytecode-enhanced entity.
|
||||
// hydratedState[i] needs to remain LazyPropertyInitializer.UNFETCHED_PROPERTY so that
|
||||
// setPropertyValues() below (ultimately AbstractEntityTuplizer#setPropertyValues) works properly
|
||||
// No resolution is necessary, unless the lazy property is a collection.
|
||||
if ( types[i].isCollectionType() ) {
|
||||
// IMPLEMENTATION NOTE: this is a lazy collection property on a bytecode-enhanced entity.
|
||||
// HHH-10989: We need to resolve the collection so that a CollectionReference is added to StatefulPersistentContext.
|
||||
// As mentioned above, hydratedState[i] needs to remain LazyPropertyInitializer.UNFETCHED_PROPERTY
|
||||
// so do not assign the resolved, unitialized PersistentCollection back to hydratedState[i].
|
||||
types[i].resolve( value, session, entity );
|
||||
}
|
||||
}
|
||||
else if ( value!= PropertyAccessStrategyBackRefImpl.UNKNOWN ) {
|
||||
// we know value != LazyPropertyInitializer.UNFETCHED_PROPERTY
|
||||
hydratedState[i] = types[i].resolve( value, session, entity );
|
||||
}
|
||||
}
|
||||
|
||||
//Must occur afterQuery resolving identifiers!
|
||||
if ( session.isEventSource() ) {
|
||||
|
|
|
@ -100,7 +100,7 @@ public class CascadeWithFkConstraintTestTask extends AbstractEnhancerTestTask {
|
|||
|
||||
// --- //
|
||||
|
||||
@Entity
|
||||
@Entity(name="Garage")
|
||||
public static class Garage {
|
||||
|
||||
@Id
|
||||
|
@ -120,7 +120,7 @@ public class CascadeWithFkConstraintTestTask extends AbstractEnhancerTestTask {
|
|||
|
||||
}
|
||||
|
||||
@Entity
|
||||
@Entity(name="Car")
|
||||
public static class Car {
|
||||
|
||||
@Id
|
||||
|
|
Loading…
Reference in New Issue