Skip to content

Commit 51d64b1

Browse files
dreab8beikov
authored andcommitted
HHH-17519 Initializing a lazy association with a non aggregate id causes a NPE
1 parent 2969b11 commit 51d64b1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,11 @@ public Fetch resolveCircularFetch(
947947
final AssociationKey associationKey = foreignKeyDescriptor.getAssociationKey();
948948
final boolean associationKeyVisited = creationState.isAssociationKeyVisited( associationKey );
949949
if ( associationKeyVisited || bidirectionalAttributePath != null ) {
950+
if ( !associationKeyVisited && creationState.isRegisteringVisitedAssociationKeys() ) {
951+
// If the current association key hasn't been visited yet and we are registering keys,
952+
// then there can't be a circular fetch
953+
return null;
954+
}
950955
NavigablePath parentNavigablePath = fetchablePath.getParent();
951956
assert parentNavigablePath.equals( fetchParent.getNavigablePath() );
952957
// 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 PrimaryKey {
10051010
);
10061011
}
10071012

1008-
if ( !associationKeyVisited && creationState.isRegisteringVisitedAssociationKeys() ) {
1009-
// If the current association key hasn't been visited yet and we are registering keys,
1010-
// then there can't be a circular fetch
1011-
return null;
1012-
}
1013-
10141013
/*
10151014
class Child {
10161015
@OneToOne

0 commit comments

Comments
 (0)