HHH-14257 An Entity A with a map collection having as index an Embeddable with a an association to the Entity A fails with a NPE
This commit is contained in:
parent
bf0b86dfea
commit
00b3ccb8ec
|
@ -666,23 +666,30 @@ public abstract class AbstractLoadPlanBuildingAssociationVisitationStrategy
|
|||
|
||||
// go ahead and build the bidirectional fetch
|
||||
if ( attributeDefinition.getAssociationNature() == AssociationAttributeDefinition.AssociationNature.ENTITY ) {
|
||||
final Joinable currentEntityPersister = (Joinable) currentSource().resolveEntityReference().getEntityPersister();
|
||||
final AssociationKey currentEntityReferenceAssociationKey =
|
||||
new AssociationKey( currentEntityPersister.getTableName(), currentEntityPersister.getKeyColumnNames() );
|
||||
// if associationKey is equal to currentEntityReferenceAssociationKey
|
||||
// that means that the current EntityPersister has a single primary key attribute
|
||||
// (i.e., derived attribute) which is mapped by attributeDefinition.
|
||||
// This is not a bidirectional association.
|
||||
// TODO: AFAICT, to avoid an overflow, the associated entity must already be loaded into the session, or
|
||||
// it must be loaded when the ID for the dependent entity is resolved. Is there some other way to
|
||||
// deal with this???
|
||||
final FetchSource registeredFetchSource = registeredFetchSource( associationKey );
|
||||
if ( registeredFetchSource != null && ! associationKey.equals( currentEntityReferenceAssociationKey ) ) {
|
||||
currentSource().buildBidirectionalEntityReference(
|
||||
attributeDefinition,
|
||||
fetchStrategy,
|
||||
registeredFetchSource( associationKey ).resolveEntityReference()
|
||||
);
|
||||
if ( registeredFetchSource != null ) {
|
||||
final ExpandingFetchSource currentSource = currentSource();
|
||||
final Joinable currentEntityPersister = (Joinable) currentSource.resolveEntityReference().getEntityPersister();
|
||||
|
||||
final AssociationKey currentEntityReferenceAssociationKey =
|
||||
new AssociationKey( currentEntityPersister.getTableName(), currentEntityPersister.getKeyColumnNames() );
|
||||
// if associationKey is equal to currentEntityReferenceAssociationKey
|
||||
// that means that the current EntityPersister has a single primary key attribute
|
||||
// (i.e., derived attribute) which is mapped by attributeDefinition.
|
||||
// This is not a bidirectional association.
|
||||
// TODO: AFAICT, to avoid an overflow, the associated entity must already be loaded into the session, or
|
||||
// it must be loaded when the ID for the dependent entity is resolved. Is there some other way to
|
||||
// deal with this???
|
||||
if ( !associationKey.equals( currentEntityReferenceAssociationKey ) ) {
|
||||
currentSource.buildBidirectionalEntityReference(
|
||||
attributeDefinition,
|
||||
fetchStrategy,
|
||||
registeredFetchSource.resolveEntityReference()
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Do nothing, no bi-directionality
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue