title: How to convert Array of Object to Custom Class Object (that is array to object)?
body: <p>I am working on a spring boot project and using JPA for querying the database with Entity manager.</p>
  <p>i.e.</p>
  <pre><code>Query query = entityManager.createNativeQuery(&quot;SELECT * FROM TABLE_NAME WHERE ID = 1&quot;); // SUPPOSE
  
  List&lt;Object[]&gt; result = (List&lt;Object[]&gt;) query.getResultList();
  </code></pre>
  <p>now after this what I want to achieve here is creating an Object of that corresponding result.</p>
  <pre><code>i.e.  ResultObject obj = (ResultObject) result.get(0); 
  // here ResultObject is user defined.
  </code></pre>
  <p>but this type of casting is not possible directly.</p>
  <p>so what I am currently doing is:</p>
  <pre><code>ResultObject obj = new ResultObject(); 
  obj.setArribute1((String) obj[0]);
  obj.setArribute2((Integer) obj[1]);
  ...
  </code></pre>
  <p><strong>and on average i will be having 15 attributes per object. so its really tiresome...</strong></p>
  <p>I have tried using:</p>
  <pre><code>List&lt;ResultObject&gt; obj = (List&lt;ResultObject&gt;)query.getResultList();
  </code></pre>
  <p><strong>but doesn't work.</strong></p>