From bc7746ac5d9a49df7b4f951d59437343207ccb02 Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Fri, 10 Nov 2023 15:31:07 +0100 Subject: [PATCH] HHH-17415 Add test for issue --- .../EntityValuedPathsGroupByOrderByTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/EntityValuedPathsGroupByOrderByTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/EntityValuedPathsGroupByOrderByTest.java index bc91bc76f7..9fb29e97cc 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/EntityValuedPathsGroupByOrderByTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/EntityValuedPathsGroupByOrderByTest.java @@ -153,6 +153,25 @@ public class EntityValuedPathsGroupByOrderByTest { ).getSingleResult().get( 1 ) ).isEqualTo( 3L ) ); } + @Test + @Jira( "https://hibernate.atlassian.net/browse/HHH-17415" ) + public void testInSubqueryGroupBy(SessionFactoryScope scope) { + scope.inTransaction( session -> assertThat( session.createQuery( + "select a from EntityA a where a.secondary in (select b2 from EntityB b2 group by b2)", + Tuple.class + ).getResultList() ).hasSize( 2 ) ); + } + + @Test + @Jira( "https://hibernate.atlassian.net/browse/HHH-17415" ) + public void testInSubqueryGroupByImplicitJoin(SessionFactoryScope scope) { + scope.inTransaction( session -> assertThat( session.createQuery( + "select a from EntityA a where a.secondary in" + + " (select a2.secondary from EntityA a2 group by a2.secondary)", + Tuple.class + ).getResultList() ).hasSize( 2 ) ); + } + @Entity( name = "EntityA" ) public static class EntityA { @Id