Skip to content

Commit 14ed32c

Browse files
DavideDbeikov
authored andcommitted
HHH-18431 Allow Hibernate Reactive to skip lazy initialization
The fix for HHH-18147 add a lazy initialization that causes regressions in Hibernate Reactive. This change makes it possible to skip the lazy initialization (Hibernate Reactive does not support it anyway) for the time being. I might find a better solution when I have time.
1 parent 3d2d449 commit 14ed32c

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,10 +2367,7 @@ private Object extractValue(Object domainValue, SharedSessionContractImplementor
23672367
}
23682368

23692369
if ( referencedPropertyName != null ) {
2370-
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( domainValue );
2371-
if ( lazyInitializer != null ) {
2372-
domainValue = lazyInitializer.getImplementation();
2373-
}
2370+
domainValue = lazyInitialize( domainValue );
23742371
assert getAssociatedEntityMappingType()
23752372
.getRepresentationStrategy()
23762373
.getInstantiator()
@@ -2381,6 +2378,18 @@ assert getAssociatedEntityMappingType()
23812378
return foreignKeyDescriptor.getAssociationKeyFromSide( domainValue, sideNature.inverse(), session );
23822379
}
23832380

2381+
/**
2382+
* For Hibernate Reactive, because it doesn't support lazy initialization, it will override this method and skip it
2383+
* when possible.
2384+
*/
2385+
protected Object lazyInitialize(Object domainValue) {
2386+
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( domainValue );
2387+
if ( lazyInitializer != null ) {
2388+
return lazyInitializer.getImplementation();
2389+
}
2390+
return domainValue;
2391+
}
2392+
23842393
private static Object extractAttributePathValue(Object domainValue, EntityMappingType entityType, String attributePath) {
23852394
if ( ! attributePath.contains( "." ) ) {
23862395
return entityType.findAttributeMapping( attributePath ).getValue( domainValue );

0 commit comments

Comments
 (0)