From c2fd2633183c5078e1da72f5c5d80b22dbf119b8 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Mon, 24 Jul 2023 15:51:03 +0200 Subject: [PATCH] HHH-16966 StackOverFlowError with @ManyToOne and @Proxy( lazy=false ) --- .../internal/EntitySelectFetchInitializerBuilder.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntitySelectFetchInitializerBuilder.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntitySelectFetchInitializerBuilder.java index d02684be10..683f275a03 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntitySelectFetchInitializerBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntitySelectFetchInitializerBuilder.java @@ -141,12 +141,8 @@ public class EntitySelectFetchInitializerBuilder { } private static boolean canBatchInitializeBeUsed(EntityPersister entityPersister) { - if ( entityPersister.getRepresentationStrategy().getProxyFactory() == null - && entityPersister.hasSubclasses() ) { - // We cannot neither create a proxy nor instantiate the entity because we don't know the concrete type - return false; - } - return true; + // we need to create a Proxy in order to use batch initialize + return entityPersister.getRepresentationStrategy().getProxyFactory() != null; } enum BatchMode {