Skip to content

Commit e57a2ab

Browse files
committed
HHH-18272 Add test for issue
1 parent 7fb23cd commit e57a2ab

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ public void testJoinSelectAndGroupByAndOrderBy(SessionFactoryScope scope) {
119119
).getSingleResult().get( 1 ) ).isEqualTo( 3L ) );
120120
}
121121

122+
@Test
123+
@Jira( "https://hibernate.atlassian.net/browse/HHH-18272" )
124+
public void testJoinSelectAliasAndGroupByAndOrderBy(SessionFactoryScope scope) {
125+
scope.inTransaction( session -> assertThat( session.createQuery(
126+
"select b as secondary, sum(a.amount) from EntityA a join a.secondary b where b.id = 1 group by secondary order by secondary",
127+
Tuple.class
128+
).getSingleResult().get( 1 ) ).isEqualTo( 3L ) );
129+
}
130+
122131
// Implicit join ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123132

124133
@Test
@@ -153,6 +162,15 @@ public void testImplicitJoinSelectAndGroupByAndOrderBy(SessionFactoryScope scope
153162
).getSingleResult().get( 1 ) ).isEqualTo( 3L ) );
154163
}
155164

165+
@Test
166+
@Jira( "https://hibernate.atlassian.net/browse/HHH-18272" )
167+
public void testImplicitJoinSelectAliasAndGroupByAndOrderBy(SessionFactoryScope scope) {
168+
scope.inTransaction( session -> assertThat( session.createQuery(
169+
"select a.secondary as a_secondary, sum(a.amount) from EntityA a where a.secondary.id = 1 group by a_secondary order by a_secondary",
170+
Tuple.class
171+
).getSingleResult().get( 1 ) ).isEqualTo( 3L ) );
172+
}
173+
156174
@Test
157175
@Jira( "https://hibernate.atlassian.net/browse/HHH-17415" )
158176
public void testInSubqueryGroupBy(SessionFactoryScope scope) {

0 commit comments

Comments
 (0)