title: JPA createNativeQuery not mapping to Entity class
body: <p>I am trying to use createNativeQuery to get a result set from my database and map it to a list of Entity objects. </p>
  
  <p>When i do</p>
  
  <pre><code>List&lt;MyObject&gt; results = this.em.createNativeQuery(query, MyClass.class).getResultList();
  </code></pre>
  
  <p>I end up with an array of Entity objects that is the correct size, and mapped to the columns correctly, but they are all the same object. The first result returned gets duplicated for every entry in my list. </p>
  
  <p><a href="https://i.stack.imgur.com/EM4t4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EM4t4.png" alt="enter image description here"></a></p>
  
  <p>In the picture above you can see that I get data back, and if i inspect the ovbjects they are mapped to my columns properly. But they are all the same object.</p>
  
  <p>But if i do</p>
  
  <pre><code>List&lt;Object[]&gt; objects = this.em.createNativeQuery(query, Object.class).getResultList();
  </code></pre>
  
  <p>I get a list of distinct Objects like it should be. But they are not mapped to my Entity class.</p>
  
  <p><a href="https://i.stack.imgur.com/BaR2M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BaR2M.png" alt="enter image description here"></a></p>
  
  <p>In the above pic, you can see that when I use <code>Object</code> and stead of my Entity class type, I get a result set of distinct objects for each row returned. I cannot figure out why when i use my Entity class it just repeats the same row over and over. </p>
  
  <p>Does anyone know what could be causing me to get a list of the same object each time?</p>
  
  <p>My query is selecting from a Pipelined function in a stored procedure</p>
  
  <pre><code>String query = "select * from table(myschema.mypackage.myfunction(input_var))";
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The pipelined function I am calling inside my procedure returns about 200 rows. For testing purposes, I have only mapped the first few of the columns. </p>
  
  <p>My Entity class has column mappings for the first 13 of the 200 columns. 
  My query that calls the function is doing a <code>select *</code>, so, it is returning all 200 columns and mapping the first 13. I thought this was a possible issue, but I just tried it with a new test class I made and doing a <code>select *</code> from a regular table into an Entity that only had 2 of the columns mapped. There was no issue. It returned a list of distinct objects. </p>
  
  <p>My conclusion is that there must be something preventing Hibernate from iterating through the result set of my pipelined function. It returns the correct number of rows, but it gets stuck on the first row and just creates that object over and over. </p>
  
  <p>The issue doesnt seem to have anything to do with my column mappings </p>