HHH-17519 Initializing a lazy association with a non aggregate id causes a NPE

This commit is contained in:
Andrea Boriero 2023-12-05 14:49:20 +01:00 committed by Christian Beikov
parent 2969b112a5
commit 51d64b11a8
1 changed files with 5 additions and 6 deletions

View File

@ -947,6 +947,11 @@ public class ToOneAttributeMapping
final AssociationKey associationKey = foreignKeyDescriptor.getAssociationKey();
final boolean associationKeyVisited = creationState.isAssociationKeyVisited( associationKey );
if ( associationKeyVisited || bidirectionalAttributePath != null ) {
if ( !associationKeyVisited && creationState.isRegisteringVisitedAssociationKeys() ) {
// If the current association key hasn't been visited yet and we are registering keys,
// then there can't be a circular fetch
return null;
}
NavigablePath parentNavigablePath = fetchablePath.getParent();
assert parentNavigablePath.equals( fetchParent.getNavigablePath() );
// The parent navigable path is {fk} if we are creating the domain result for the foreign key for a circular fetch
@ -1005,12 +1010,6 @@ public class ToOneAttributeMapping
);
}
if ( !associationKeyVisited && creationState.isRegisteringVisitedAssociationKeys() ) {
// If the current association key hasn't been visited yet and we are registering keys,
// then there can't be a circular fetch
return null;
}
/*
class Child {
@OneToOne