HHH-18862 Add test for issue

This commit is contained in:
Marco Belladelli 2024-11-19 10:36:10 +01:00
parent dd80b3e2a5
commit 39f78c89fd
1 changed files with 29 additions and 0 deletions

View File

@ -188,6 +188,35 @@ public class EntityValuedPathsGroupByOrderByTest {
).getResultList() ).hasSize( 2 ) );
}
@Test
@Jira( "https://hibernate.atlassian.net/browse/HHH-18862" )
public void testSubquerySelectionGroupBy(SessionFactoryScope scope) {
scope.inTransaction( session -> assertThat( session.createQuery(
"select (select s.id from EntityB ignore) from EntityA a join a.secondary s group by s.id",
Long.class
).getSingleResult() ).isEqualTo( 1L ) );
}
@Test
@Jira( "https://hibernate.atlassian.net/browse/HHH-18862" )
public void testSubquerySelectionGroupByAndOrderBy(SessionFactoryScope scope) {
scope.inTransaction( session -> assertThat( session.createQuery(
"select (select s.id from EntityB ignore) from EntityA a"
+ " join a.secondary s group by s.id order by s.id",
Long.class
).getSingleResult() ).isEqualTo( 1L ) );
}
@Test
@Jira( "https://hibernate.atlassian.net/browse/HHH-18862" )
public void testSubquerySelectionGroupByAndOrderByImplicit(SessionFactoryScope scope) {
scope.inTransaction( session -> assertThat( session.createQuery(
"select (select a.secondary.id from EntityB ignore) from EntityA a"
+ " group by a.secondary.id order by a.secondary.id",
Long.class
).getSingleResult() ).isEqualTo( 1L ) );
}
@Entity( name = "EntityA" )
public static class EntityA {
@Id