Skip to content

Commit ac3b528

Browse files
committed
HHH-17445 Don't force initialization of correlated joined table group
1 parent e369015 commit ac3b528

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3741,8 +3741,6 @@ private TableGroup createTableGroup(TableGroup parentTableGroup, SqmPath<?> join
37413741
querySpec::applyPredicate,
37423742
this
37433743
);
3744-
// Force initialization of a possible lazy table group
3745-
tableGroup.getPrimaryTableReference();
37463744
querySpec.getFromClause().addRoot( tableGroup );
37473745
}
37483746
else {

hibernate-core/src/test/java/org/hibernate/orm/test/query/ImplicitJoinInSubqueryTest.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
2020

21-
@JiraKey("HHH-16721")
2221
@DomainModel(annotatedClasses = {
2322
ImplicitJoinInSubqueryTest.A.class,
2423
ImplicitJoinInSubqueryTest.B.class,
@@ -28,6 +27,7 @@
2827
public class ImplicitJoinInSubqueryTest {
2928

3029
@Test
30+
@JiraKey("HHH-16721")
3131
public void testImplicitJoinInSubquery(SessionFactoryScope scope) {
3232
SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
3333
statementInspector.clear();
@@ -41,6 +41,22 @@ public void testImplicitJoinInSubquery(SessionFactoryScope scope) {
4141
);
4242
}
4343

44+
@Test
45+
@JiraKey("HHH-17445")
46+
public void testImplicitJoinInSubquery2(SessionFactoryScope scope) {
47+
SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
48+
statementInspector.clear();
49+
scope.inTransaction(
50+
entityManager -> {
51+
entityManager.createSelectionQuery(
52+
"select a from A a where exists (select 1 from B b where a.b.c is null)"
53+
).getResultList();
54+
assertThat( statementInspector.getSqlQueries().get( 0 ) ).contains( "b1_0.c_id is null" );
55+
assertThat( statementInspector.getSqlQueries().get( 0 ) ).doesNotContain( ".id=b1_0.c_id" );
56+
}
57+
);
58+
}
59+
4460
@Entity(name = "A")
4561
public static class A {
4662
@Id

0 commit comments

Comments
 (0)