Skip to content

Commit

Permalink
HHH-17445 Don't force initialization of correlated joined table group
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed Dec 1, 2023
1 parent 314c621 commit e0875a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3786,8 +3786,6 @@ private TableGroup createTableGroup(TableGroup parentTableGroup, SqmPath<?> join
querySpec::applyPredicate,
this
);
// Force initialization of a possible lazy table group
tableGroup.getPrimaryTableReference();
querySpec.getFromClause().addRoot( tableGroup );
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

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

@JiraKey("HHH-16721")
@DomainModel(annotatedClasses = {
ImplicitJoinInSubqueryTest.A.class,
ImplicitJoinInSubqueryTest.B.class,
Expand All @@ -28,6 +27,7 @@
public class ImplicitJoinInSubqueryTest {

@Test
@JiraKey("HHH-16721")
public void testImplicitJoinInSubquery(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear();
Expand All @@ -41,6 +41,22 @@ public void testImplicitJoinInSubquery(SessionFactoryScope scope) {
);
}

@Test
@JiraKey("HHH-17445")
public void testImplicitJoinInSubquery2(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear();
scope.inTransaction(
entityManager -> {
entityManager.createSelectionQuery(
"select a from A a where exists (select 1 from B b where a.b.c is null)"
).getResultList();
assertThat( statementInspector.getSqlQueries().get( 0 ) ).contains( "b1_0.c_id is null" );
assertThat( statementInspector.getSqlQueries().get( 0 ) ).doesNotContain( ".id=b1_0.c_id" );
}
);
}

@Entity(name = "A")
public static class A {
@Id
Expand Down

0 comments on commit e0875a1

Please sign in to comment.