diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/SelectCaseWhenNullLiteralTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/SelectCaseWhenNullLiteralTest.java index 836e7df34a..330e804078 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/SelectCaseWhenNullLiteralTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/SelectCaseWhenNullLiteralTest.java @@ -4,6 +4,7 @@ import java.util.List; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.JiraKey; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.junit.jupiter.api.AfterEach; @@ -55,6 +56,30 @@ public class SelectCaseWhenNullLiteralTest { ); } + @Test + @JiraKey( "HHH-18556" ) + public void testSelectCaseWhenNullLiteralWithParameters(SessionFactoryScope scope) { + scope.inTransaction( + session -> { + List result = session.createQuery( "select case when 1=1 then ?1 else null end from Person p" ) + .setParameter( 1, 2 ) + .list(); + assertThat( result.size(), is( 1 ) ); + assertThat( result.get( 0 ), is( 2 ) ); + } + ); + + scope.inTransaction( + session -> { + List result = session.createQuery( "select count(case when 1=1 then ?1 else null end) from Person p" ) + .setParameter( 1, 2 ) + .list(); + assertThat( result.size(), is( 1 ) ); + assertThat( result.get( 0 ), is( 1L ) ); + } + ); + } + @Entity(name = "Person") @Table(name = "PERSON_TABLE") public static class Person {