Skip to content

Commit 39f78c8

Browse files
committed
HHH-18862 Add test for issue
1 parent dd80b3e commit 39f78c8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,35 @@ public void testInSubqueryGroupByImplicitJoin(SessionFactoryScope scope) {
188188
).getResultList() ).hasSize( 2 ) );
189189
}
190190

191+
@Test
192+
@Jira( "https://hibernate.atlassian.net/browse/HHH-18862" )
193+
public void testSubquerySelectionGroupBy(SessionFactoryScope scope) {
194+
scope.inTransaction( session -> assertThat( session.createQuery(
195+
"select (select s.id from EntityB ignore) from EntityA a join a.secondary s group by s.id",
196+
Long.class
197+
).getSingleResult() ).isEqualTo( 1L ) );
198+
}
199+
200+
@Test
201+
@Jira( "https://hibernate.atlassian.net/browse/HHH-18862" )
202+
public void testSubquerySelectionGroupByAndOrderBy(SessionFactoryScope scope) {
203+
scope.inTransaction( session -> assertThat( session.createQuery(
204+
"select (select s.id from EntityB ignore) from EntityA a"
205+
+ " join a.secondary s group by s.id order by s.id",
206+
Long.class
207+
).getSingleResult() ).isEqualTo( 1L ) );
208+
}
209+
210+
@Test
211+
@Jira( "https://hibernate.atlassian.net/browse/HHH-18862" )
212+
public void testSubquerySelectionGroupByAndOrderByImplicit(SessionFactoryScope scope) {
213+
scope.inTransaction( session -> assertThat( session.createQuery(
214+
"select (select a.secondary.id from EntityB ignore) from EntityA a"
215+
+ " group by a.secondary.id order by a.secondary.id",
216+
Long.class
217+
).getSingleResult() ).isEqualTo( 1L ) );
218+
}
219+
191220
@Entity( name = "EntityA" )
192221
public static class EntityA {
193222
@Id

0 commit comments

Comments
 (0)