Skip to content

Commit cda93c6

Browse files
cigalybeikov
authored andcommitted
HHH-19719 Test case - when SelfRenderingSqmWindowFunction has no arguments, appendHqlString throws IndexOutOfBoundsException
1 parent 4e85cdb commit cda93c6

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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.DialectFeatureChecks.SupportPartitionBy;
10+
import org.hibernate.testing.orm.junit.DomainModel;
11+
import org.hibernate.testing.orm.junit.JiraKey;
12+
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
13+
import org.hibernate.testing.orm.junit.SessionFactory;
14+
import org.hibernate.testing.orm.junit.SessionFactoryScope;
15+
import org.junit.jupiter.api.BeforeAll;
16+
import org.junit.jupiter.api.Test;
17+
18+
@DomainModel(
19+
annotatedClasses = SelfRenderingSqmFunctionWithoutArgumentsTest.Dummy.class
20+
)
21+
@SessionFactory
22+
@JiraKey("HHH-19719")
23+
@RequiresDialectFeature(feature = SupportPartitionBy.class)
24+
public class SelfRenderingSqmFunctionWithoutArgumentsTest {
25+
26+
@BeforeAll
27+
static void init(SessionFactoryScope scope) {
28+
scope.inTransaction( session -> {
29+
session.persist( new Dummy(1, "John Doe") );
30+
session.persist( new Dummy(2, "Dave Default") );
31+
} );
32+
}
33+
34+
@Test
35+
void test(SessionFactoryScope scope) {
36+
scope.inSession( session -> {
37+
session.createQuery( """
38+
with tmp as (
39+
select id id, name name, row_number() over (order by name) pos
40+
from Dummy
41+
)
42+
select id, name, pos from tmp
43+
""" ).getResultList();
44+
} );
45+
46+
}
47+
48+
@Entity(name = "Dummy")
49+
static class Dummy {
50+
@Id
51+
private Integer id;
52+
53+
private String name;
54+
55+
private Dummy() {
56+
// for use by Hibernate
57+
}
58+
59+
public Dummy(Integer id, String name) {
60+
this.id = id;
61+
this.name = name;
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)