Inconsistent "SELECT 1" versus "SELECT ?1" with result type Object[]

Hi,

I am using Hibernate 6.5.2 and I discovered a very strange behaviour:

  • if I execute session.createQuery("select ?1", Object[].class).setParameter(1, 1).getSingleResult(), I get a Long returned
  • if I execute session.createQuery("select 1", Object[].class).getSingleResult() I get an Object returned with the result as the first element

Is this expected?

And it is the same when using named parameters.

Both queries should return an object array, so this is a bug.
Please try to create a reproducer with our test case template and if you are able to reproduce the issue, create a bug ticket in our issue tracker and attach that reproducer.

Here it is: [HHH-18450] - Hibernate JIRA

1 Like