Reputation: 18438
I am trying to return custom object from spring data jpa - native query
Here's what I've done so far according to this How to return a custom object from a Spring Data JPA GROUP BY query
I should be able to create query like this:
Query(nativeQuery = true, value = "select sc.case_type as caseType, sc.revision as revision from smart_casemodel sc minus select s.casetype, s.revision from smart_case s")
List<CtRevOnly> findNotUsedCasemodels();
I declared projection Interface
public interface CtRevOnly {
String getCaseType();
String getRevision();
}
Then simply call it
caseModelRepository.findNotUsedCasemodels();
however I get an exception
javax.persistence.PersistenceException: org.hibernate.MappingException: Unknown entity: javax.persistence.Tuple
Any idea what am I doing wrong ?
Upvotes: 4
Views: 1969
Reputation: 18438
For anyone running into the same problem
I am using Hibernate 5.1.2.Final
I guess there's a bug and I need to upgrade to hibernate 5.2.11 to make it work See this link
Upvotes: 2