Skip to content

Commit d82d352

Browse files
committed
HHH-19719 Test case - when SelfRenderingSqmWindowFunction has no arguments, appendHqlString throws IndexOutOfBoundsException
1 parent be72098 commit d82d352

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.orm.test.query.sqm;
6+
7+
import jakarta.persistence.Entity;
8+
import jakarta.persistence.Id;
9+
import org.hibernate.testing.orm.junit.DomainModel;
10+
import org.hibernate.testing.orm.junit.JiraKey;
11+
import org.hibernate.testing.orm.junit.SessionFactory;
12+
import org.hibernate.testing.orm.junit.SessionFactoryScope;
13+
import org.junit.jupiter.api.BeforeAll;
14+
import org.junit.jupiter.api.Test;
15+
16+
@DomainModel(
17+
annotatedClasses = SelfRenderingSqmFunctionWithoutArgumentsTest.Dummy.class
18+
)
19+
@SessionFactory
20+
@JiraKey("HHH-19719")
21+
public class SelfRenderingSqmFunctionWithoutArgumentsTest {
22+
23+
@BeforeAll
24+
static void init(SessionFactoryScope scope) {
25+
scope.inTransaction( session -> {
26+
session.persist( new Dummy(1, "John Doe") );
27+
session.persist( new Dummy(2, "Dave Default") );
28+
} );
29+
}
30+
31+
@Test
32+
void test(SessionFactoryScope scope) {
33+
scope.inSession( session -> {
34+
session.createQuery( """
35+
with tmp as (
36+
select id id, name name, row_number() over (order by name) rank
37+
from Dummy
38+
)
39+
select id, name, rank from tmp
40+
""" ).getResultList();
41+
} );
42+
43+
}
44+
45+
@Entity(name = "Dummy")
46+
static class Dummy {
47+
@Id
48+
private Integer id;
49+
50+
private String name;
51+
52+
private Dummy() {
53+
// for use by Hibernate
54+
}
55+
56+
public Dummy(Integer id, String name) {
57+
this.id = id;
58+
this.name = name;
59+
}
60+
}
61+
}

0 commit comments

Comments
 (0)