createNativeQuery has two versions, the old one and the new one with generics. The following call returns a List of Unit even though it is technically only a List: {{ createNativeQuery("SELECT {u.*} FROM Unit u") .addEntity("u", Unit.class) .list() }} But the following (that is supposed to explicitly return a List<Unit>) crashes with an exception org.hibernate.exception.GenericJDBCException: could not execute query: {{ createNativeQuery("SELECT {u.*} FROM Unit u", Unit.class) .addEntity("u", Unit.class) .list() }}
It appears that the generated SQL statement set aliases starting indexing with 1, but when the result is being extracted the aliases are assumed to be indexed from 0 and that causes the error. |
|