title: JPA : How to convert a native query result set to POJO class collection
body: <p>I am using JPA in my project.</p>
  
  <p>I came to a query in which I need to make join operation on five tables. So I created a native query which returns five fields.</p>
  
  <p>Now I want to convert the result object to java POJO class which contains the same five Strings.</p>
  
  <p>Is there any way in JPA to directly cast that result to POJO object list ??</p>
  
  <p>I came to the following solution ..</p>
  
  <pre><code>@NamedNativeQueries({  
      @NamedNativeQuery(  
          name = "nativeSQL",  
          query = "SELECT * FROM Actors",  
          resultClass = db.Actor.class),  
      @NamedNativeQuery(  
          name = "nativeSQL2",  
          query = "SELECT COUNT(*) FROM Actors",  
          resultClass = XXXXX) // &lt;--------------- problem  
  })  
  </code></pre>
  
  <p>Now here in resultClass, do we need to provide a class which is actual JPA entity ?
  OR
  We can convert it to any JAVA POJO class which contains the same column names ?</p>