title: Getting column names from a JPA Native Query
body: <p>I have an administrative console in my web application that allows an admin to perform a custom SQL SELECT query on our database.</p>
  
  <p>Underneath, the application is using Hibernate, but these queries are not HQL, they're pure SQL, so I'm using a Native Query like this:</p>
  
  <pre><code>protected EntityManager em;
  
  public List&lt;Object[]&gt; execute(String query) {
      Query q = em.createNativeQuery(query);
      List&lt;Object[]&gt; result = q.getResultList();
      return result;
  }
  </code></pre>
  
  <p>This works correctly, but it only returns the rows of data, with no extra information. What I would like is to also get the column names, so when I print the results back to the user I can also print a header to show what the various columns are.</p>
  
  <p>Is there any way to do this?</p>