My question is based on another post. How can I achieve the same with a native query? Native queries do not allow JPQL thus do not allow new instances either.
My POJ
This is https://jira.spring.io/browse/DATAJPA-980 and Here is a project that demonstrates the issue.
@Query(value = "SELECT name AS name, age AS age FROM Person", nativeQuery = true)
List findAllProjectedNativeQuery();
It is fixed in the Spring Data JPA 2.0 GA (Kay) release which comes with Hibernate 5.2.11.
The issue is also fixed for Spring Data 1.10.12 (Ingalls) and 1.11.8 (Hopper) but will need to be run on Hibernate 5.2.11 to work.