title: How to return custom object using projection in Spring Data Jpa?
body: <p>I am trying to return custom object from spring data jpa - <strong>native query</strong></p>
  
  <p>Here's what I've done so far according to this
  <a href="https://stackoverflow.com/questions/36328063/how-to-return-a-custom-object-from-a-spring-data-jpa-group-by-query">How to return a custom object from a Spring Data JPA GROUP BY query</a></p>
  
  <p>I should be able to create query like this:</p>
  
  <pre><code>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&lt;CtRevOnly&gt; findNotUsedCasemodels();
  </code></pre>
  
  <p>I declared projection Interface</p>
  
  <pre><code>public interface CtRevOnly {
      String getCaseType();
      String getRevision();
  }
  </code></pre>
  
  <p>Then simply call it</p>
  
  <pre><code>caseModelRepository.findNotUsedCasemodels();
  </code></pre>
  
  <p>however I get an exception</p>
  
  <blockquote>
    <p>javax.persistence.PersistenceException:
    org.hibernate.MappingException: Unknown entity:
    javax.persistence.Tuple</p>
  </blockquote>
  
  <p>Any idea what am I doing wrong ?</p>