We are in the process of migrating an application from Hibernate 4.3 to Hibernate 6.2. Within our application, we can create custom reports that rely on the aliases provided in the custom HQL when rendering the table. In Hibernate 4, we used String[] alias = query.getReturnAliases(); which no longer exists. So Hibernate 6, we have started using jakarta.persistence.Tuple as the result class for the query. However, if the same column is returned two times, with different aliases, calling Tuple.getElements() throws ArrayIndexOutOfBoundsException. Here is an example. Imagine a simple entity:
And the following code that runs the following query select name as Reference, name as Name, value as Value from TestEntity returning the name column two times:
Calling tuple.getElements() on line 6 results in the following exception:
The problem only occurs when the same column is listed two times (in any position). This can happen as our custom reports are used to provide integration data with other applications, which may need the same property listed two times under different names. See the attached files for the whole test. |