title: How to use JPA to select native table columns?
body: <p>I want to select a few column from a table using JPA.
  In this case I am not interessted in complete Entities, but just in a few columns with certain Ids. </p>
  
  <p>So this is my approach:</p>
  
  <pre><code>EntityManager em = createEntityManager();
  List&lt;Object[]&gt; data = em.createNativeQuery( "SELECT ID, FOREIGN_OBJ_1_ID, FOREIGN_OBJ_2_ID FROM TABLE1" ).getResultList();
  em.close();
  
  for ( Object[] row : rentaldata )
  {
       Long id = ( (BigDecimal) row[0] ).longValue();
       Long fk_1 = ((Long) row[1]);
       Long fk_2 = ((Long) row[2]);
  
        DataObject do = new DataObject(id, fk_1, fk_2, ...);
  ...
  </code></pre>
  
  <p>I tried also with JPA select new .... but I want be be sure no Objects are created. 
  So my question is: Is there any better approach to load several columns and put them into an object that this ?</p>
  
  <p>thanks,
  Thorsten</p>