HHH-16673 Fail to get access lazy fetched field ( @ManyToOne ) wich is part of a composite Id (using an @IdClass) when stored in L2 cache
This commit is contained in:
parent
036631f42c
commit
a64748ba84
|
@ -41,10 +41,9 @@ import org.hibernate.sql.results.graph.DomainResultCreationState;
|
||||||
import org.hibernate.sql.results.graph.Fetch;
|
import org.hibernate.sql.results.graph.Fetch;
|
||||||
import org.hibernate.sql.results.graph.FetchParent;
|
import org.hibernate.sql.results.graph.FetchParent;
|
||||||
import org.hibernate.sql.results.graph.Fetchable;
|
import org.hibernate.sql.results.graph.Fetchable;
|
||||||
import org.hibernate.sql.results.graph.embeddable.internal.EmbeddableFetchImpl;
|
|
||||||
import org.hibernate.sql.results.graph.embeddable.internal.EmbeddableResultImpl;
|
|
||||||
import org.hibernate.sql.results.graph.embeddable.internal.NonAggregatedIdentifierMappingFetch;
|
import org.hibernate.sql.results.graph.embeddable.internal.NonAggregatedIdentifierMappingFetch;
|
||||||
import org.hibernate.sql.results.graph.embeddable.internal.NonAggregatedIdentifierMappingResult;
|
import org.hibernate.sql.results.graph.embeddable.internal.NonAggregatedIdentifierMappingResult;
|
||||||
|
import org.hibernate.sql.results.graph.entity.LoadingEntityEntry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A "non-aggregated" composite identifier.
|
* A "non-aggregated" composite identifier.
|
||||||
|
@ -274,8 +273,7 @@ public class NonAggregatedIdentifierMappingImpl extends AbstractCompositeIdentif
|
||||||
Object o = mappedIdAttributeMapping.getPropertyAccess().getGetter().get( id );
|
Object o = mappedIdAttributeMapping.getPropertyAccess().getGetter().get( id );
|
||||||
if ( attribute instanceof ToOneAttributeMapping && !( mappedIdAttributeMapping instanceof ToOneAttributeMapping ) ) {
|
if ( attribute instanceof ToOneAttributeMapping && !( mappedIdAttributeMapping instanceof ToOneAttributeMapping ) ) {
|
||||||
final ToOneAttributeMapping toOneAttributeMapping = (ToOneAttributeMapping) attribute;
|
final ToOneAttributeMapping toOneAttributeMapping = (ToOneAttributeMapping) attribute;
|
||||||
final EntityPersister entityPersister = toOneAttributeMapping.getEntityMappingType()
|
final EntityPersister entityPersister = toOneAttributeMapping.getEntityMappingType().getEntityPersister();
|
||||||
.getEntityPersister();
|
|
||||||
final EntityKey entityKey = session.generateEntityKey( o, entityPersister );
|
final EntityKey entityKey = session.generateEntityKey( o, entityPersister );
|
||||||
final PersistenceContext persistenceContext = session.getPersistenceContext();
|
final PersistenceContext persistenceContext = session.getPersistenceContext();
|
||||||
// it is conceivable there is a proxy, so check that first
|
// it is conceivable there is a proxy, so check that first
|
||||||
|
@ -290,6 +288,21 @@ public class NonAggregatedIdentifierMappingImpl extends AbstractCompositeIdentif
|
||||||
toOneAttributeMapping.getAttributeName()
|
toOneAttributeMapping.getAttributeName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if ( o == null ) {
|
||||||
|
final LoadingEntityEntry loadingEntityEntry = persistenceContext.getLoadContexts()
|
||||||
|
.findLoadingEntityEntry( entityKey );
|
||||||
|
if ( loadingEntityEntry != null ) {
|
||||||
|
o = loadingEntityEntry.getEntityInstance();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
o = session.internalLoad(
|
||||||
|
entityPersister.getEntityName(),
|
||||||
|
entityKey.getIdentifier(),
|
||||||
|
true,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
propertyValues[i] = o;
|
propertyValues[i] = o;
|
||||||
|
|
Loading…
Reference in New Issue