|
| 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