title: Map sql query result to java object(in Non-Entity class) using spring jpa
body: <p>I want to assign SQL query result to Java object which is in non-entity class.
  My query is counting the number of records in Table A mapped to another Table B.</p>
  
  <pre><code>@Query(value="select count(a.id) from table1 a join table2 b on a.id=b.id group by a.id", nativeQuery=true)
  </code></pre>
  
  <p>Non-Entity class</p>
  
  <pre><code>   public class Sample {
  
      //assign query result to count variable
      private long count;
     // getters and setters
  
  
      }
  </code></pre>
  
  <p>A and B are Entity class, I'm selecting specified columns of Entity A and B and including that columns in Sample.class and sending data as JSON on REST call.</p>
  
  <p>Now my question is to assign count result to count variable.</p>
  
  <p>Thanks in advance</p>