Skip to content

Allow Hibernate Reactive to skip lazy initialization #8716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2367,10 +2367,7 @@ private Object extractValue(Object domainValue, SharedSessionContractImplementor
}

if ( referencedPropertyName != null ) {
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( domainValue );
if ( lazyInitializer != null ) {
domainValue = lazyInitializer.getImplementation();
}
domainValue = lazyInitialize( domainValue );
assert getAssociatedEntityMappingType()
.getRepresentationStrategy()
.getInstantiator()
Expand All @@ -2381,6 +2378,18 @@ assert getAssociatedEntityMappingType()
return foreignKeyDescriptor.getAssociationKeyFromSide( domainValue, sideNature.inverse(), session );
}

/**
* For Hibernate Reactive, because it doesn't support lazy initialization, it will override this method and skip it
* when possible.
*/
protected Object lazyInitialize(Object domainValue) {
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( domainValue );
if ( lazyInitializer != null ) {
return lazyInitializer.getImplementation();
}
return domainValue;
}

private static Object extractAttributePathValue(Object domainValue, EntityMappingType entityType, String attributePath) {
if ( ! attributePath.contains( "." ) ) {
return entityType.findAttributeMapping( attributePath ).getValue( domainValue );
Expand Down