Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void appendHqlString(StringBuilder sb) {
sb.append( getFunctionName() );
sb.append( '(' );
int i = 1;
if ( arguments.get( 0 ) instanceof SqmDistinct<?> ) {
if ( !arguments.isEmpty() && arguments.get( 0 ) instanceof SqmDistinct<?> ) {
arguments.get( 0 ).appendHqlString( sb );
if ( arguments.size() > 1 ) {
sb.append( ' ' );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.orm.test.query.sqm;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import org.hibernate.testing.orm.junit.DialectFeatureChecks.SupportPartitionBy;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

@DomainModel(
annotatedClasses = SelfRenderingSqmFunctionWithoutArgumentsTest.Dummy.class
)
@SessionFactory
@JiraKey("HHH-19719")
@RequiresDialectFeature(feature = SupportPartitionBy.class)
public class SelfRenderingSqmFunctionWithoutArgumentsTest {

@BeforeAll
static void init(SessionFactoryScope scope) {
scope.inTransaction( session -> {
session.persist( new Dummy(1, "John Doe") );
session.persist( new Dummy(2, "Dave Default") );
} );
}

@Test
void test(SessionFactoryScope scope) {
scope.inSession( session -> {
session.createQuery("with tmp as (" +
" select id id, name name, row_number() over (order by name) pos" +
" from Dummy" +
")" +
"select id, name, pos from tmp").getResultList();
Comment on lines +39 to +43

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note test

Invoking
QueryProducerImplementor.createQuery
should be avoided because it has been deprecated.
} );

}

@Entity(name = "Dummy")
static class Dummy {
@Id
private Integer id;

private String name;

private Dummy() {
// for use by Hibernate
}

public Dummy(Integer id, String name) {
this.id = id;
this.name = name;
}
}
}