From d108a47a7d365c95698ff984f4e145d494fd74f3 Mon Sep 17 00:00:00 2001 From: Barry LaFond Date: Thu, 24 Aug 2023 09:17:39 -0500 Subject: [PATCH] HHH-17130 remove restrictive instanceof EntityResultInitializer check --- .../hibernate/engine/spi/SubselectFetch.java | 23 +------------------ 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SubselectFetch.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SubselectFetch.java index dff5611937..365fe6cba8 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SubselectFetch.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SubselectFetch.java @@ -150,11 +150,7 @@ public class SubselectFetch { } public void addKey(EntityKey key, LoadingEntityEntry entry) { - if ( !entry.getDescriptor().hasSubselectLoadableCollections() ) { - return; - } - - if ( shouldAddSubselectFetch( entry ) ) { + if ( entry.getDescriptor().hasSubselectLoadableCollections() ) { final SubselectFetch subselectFetch = subselectFetches.computeIfAbsent( entry.getEntityInitializer().getNavigablePath(), navigablePath -> new SubselectFetch( @@ -171,22 +167,5 @@ public class SubselectFetch { batchFetchQueue.addSubselect( key, subselectFetch ); } } - - private boolean shouldAddSubselectFetch(LoadingEntityEntry entry) { - if ( entry.getEntityInitializer() instanceof EntityResultInitializer ) { - return true; - } - - final NavigablePath entityInitializerParent = entry.getEntityInitializer().getNavigablePath().getParent(); - - // We want to add only the collections of the loading entities - for ( DomainResult domainResult : loadingSqlAst.getDomainResultDescriptors() ) { - if ( domainResult.getNavigablePath().equals( entityInitializerParent ) ) { - return true; - } - } - - return false; - } } }