From f9bc29f4849e0bd5b7a413459c5946c9371ee38b Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Wed, 1 Mar 2023 11:04:13 +0100 Subject: [PATCH] HHH-16213 Avoid initializing lazy table group joins in AbstractSqlAstWalker --- .../org/hibernate/sql/ast/spi/AbstractSqlAstWalker.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstWalker.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstWalker.java index 6c75f437f9..bcd34df9b0 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstWalker.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstWalker.java @@ -434,7 +434,12 @@ public class AbstractSqlAstWalker implements SqlAstWalker { @Override public void visitTableGroupJoin(TableGroupJoin tableGroupJoin) { - tableGroupJoin.getJoinedGroup().accept( this ); + final TableGroup joinedGroup = tableGroupJoin.getJoinedGroup(); + if ( joinedGroup.isInitialized() ) { + // Only process already initialized table groups to avoid + // forced initialization of joined lazy table groups + joinedGroup.accept( this ); + } if ( tableGroupJoin.getPredicate() != null ) { tableGroupJoin.getPredicate().accept( this ); }