Hibernate 5.2 - ResultTransformer not working for select new queries?

Hello,

recently I migrated from Spring Boot 1.5.8 to 2.0.0
(and thus from Hibernate 5.0.12.Final to Hibernate 5.2.14.Final).

However, when using “select new” named queries similar to the following one

SELECT new sk.chgolian.simple.ShortInfo(se.id, se.shortDescription) FROM sk.chgolian.simple.SimpleEntity se

I’ve been getting IllegalArgumentException:
org.hibernate.QueryException: ResultTransformer is not allowed for 'select new' queries.

I was able to reproduce this issue in this small project.
Running
mvn test
and then
mvn test -P test-1.5
should demonstrate and reproduce my issue
(with test passing in the first instance and failing in the second one).

I haven’t been able to find any information about ResultTransformer and these queries being deprecated in the newer versions of Hibernate.
Am I doing something wrong?

Thank you for any help!

You don’t need to use the ResultTransformer if you select DTOs. The ResultTransformer is used to transform the Object[] result set into a custom DTOs, so it’s an alternative to the JPA constructor result.

I’m having the same problem, without using a ResultTransformer. It’s just a named query. As stated here it might be a problem of spring data.