Skip to content

Commit 50c84ed

Browse files
cigalybeikov
authored andcommitted
HHH-19719 Test case - when SelfRenderingSqmWindowFunction has no arguments, appendHqlString throws IndexOutOfBoundsException
1 parent b20e686 commit 50c84ed

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+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
5+
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
6+
*/
7+
package org.hibernate.orm.test.query.sqm;
8+
9+
import jakarta.persistence.Entity;
10+
import jakarta.persistence.Id;
11+
import org.hibernate.testing.orm.junit.DialectFeatureChecks.SupportPartitionBy;
12+
import org.hibernate.testing.orm.junit.DomainModel;
13+
import org.hibernate.testing.orm.junit.JiraKey;
14+
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
15+
import org.hibernate.testing.orm.junit.SessionFactory;
16+
import org.hibernate.testing.orm.junit.SessionFactoryScope;
17+
import org.junit.jupiter.api.BeforeAll;
18+
import org.junit.jupiter.api.Test;
19+
20+
@DomainModel(
21+
annotatedClasses = SelfRenderingSqmFunctionWithoutArgumentsTest.Dummy.class
22+
)
23+
@SessionFactory
24+
@JiraKey("HHH-19719")
25+
@RequiresDialectFeature(feature = SupportPartitionBy.class)
26+
public class SelfRenderingSqmFunctionWithoutArgumentsTest {
27+
28+
@BeforeAll
29+
static void init(SessionFactoryScope scope) {
30+
scope.inTransaction( session -> {
31+
session.persist( new Dummy(1, "John Doe") );
32+
session.persist( new Dummy(2, "Dave Default") );
33+
} );
34+
}
35+
36+
@Test
37+
void test(SessionFactoryScope scope) {
38+
scope.inSession( session -> {
39+
session.createQuery("with tmp as (" +
40+
" select id id, name name, row_number() over (order by name) pos" +
41+
" from Dummy" +
42+
")" +
43+
"select id, name, pos from tmp").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)