title: How retrieve information from a SQL query
body: <p>Having <code>createNativeQuery</code> </p>
  
  <blockquote>
    <p>SELECT c.name, c.breed, c.weight FROM cat c</p>
  </blockquote>
  
  <p>such also</p>
  
  <blockquote>
    <p>SELECT Customers.CustomerName, Orders.OrderID FROM Customers LEFT JOIN
    Orders ON Customers.CustomerID=Orders.CustomerID ORDER BY
    Customers.CustomerName;</p>
  </blockquote>
  
  <p>I would like to pull out information such as:</p>
  
  <ul>
  <li>cat.name </li>
  <li>cat.breed</li>
  <li>cat.weight</li>
  </ul>
  
  <p>It is possible to obtain such information using Hibernate 5/JPA 2.1?</p>
  
  <p>Alternatively, if it is possible to obtain these data with metadata? I found a solution to get Connection with EntityManager, then you can draw any metadata. Unfortunately, this is the solution for Hibernate 4/JPA 2.0, not work in Hibernate 5/JPA 2.1.</p>
  
  <pre><code>Session session = em.unwrap(Session.class);
  SessionFactoryImplementor sfi = (SessionFactoryImplementor) session.getSessionFactory();
  ConnectionProvider cp = sfi.getConnectionProvider();
  Connection conn = cp.getConnection();
  </code></pre>