I have the following JPQL-query:
SELECT new se.callista.test.dto.EmployeeReportData(e.firstName, e.lastName, a.city, e.employmentPeriod.startDate) FROM Employee e JOIN e.address a ORDER BY e.lastName, e.firstName
where EmployeeReportData is a dto (not an entity). The query works fine when running it as a normal query. When I put it as a named query however, I get the following error message when trying to execute it: java.lang.IllegalArgumentException: Not an entity:class se.callista.test.dto.EmployeeReportData
I can't find anything in the JPA-spec that says a named query cannot contain a constructor expression - am I missing something?