Skip to content

Commit 6c690f5

Browse files
dreab8beikov
authored andcommitted
HHH-16960 OneToOne lazy loading fails when fetch graph is involved
1 parent a73bc08 commit 6c690f5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1630,9 +1630,12 @@ else if ( hasNotFoundAction()
16301630
final boolean selectByUniqueKey = isSelectByUniqueKey( side );
16311631

16321632
// Consider all associations annotated with @NotFound as EAGER
1633+
// and LAZY one-to-one that are not instrumented and not optional
16331634
if ( fetchTiming == FetchTiming.IMMEDIATE
16341635
|| hasNotFoundAction()
1635-
|| getAssociatedEntityMappingType().getSoftDeleteMapping() != null ) {
1636+
|| getAssociatedEntityMappingType().getSoftDeleteMapping() != null
1637+
|| ( !entityMappingType.getEntityPersister().isInstrumented()
1638+
&& cardinality == Cardinality.ONE_TO_ONE && isOptional ) ) {
16361639
return buildEntityFetchSelect(
16371640
fetchParent,
16381641
this,

0 commit comments

Comments
 (0)