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; - } } }