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 c012abf528..ceae9817ea 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 @@ -55,6 +55,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 {