title: hibernate native query, count
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1372317/how-do-we-count-rows-using-hibernate">How do we count rows using Hibernate?</a>  </p>
  </blockquote>
  
  
  
  <p>I want count number of records by criteria in database.<br>
  I try use next query  </p>
  
  <pre><code>String queryString = "SELECT Count(*) FROM my_table";  
  Query query = entityManager.createNativeQuery(queryString);  
  </code></pre>
  
  <p>but there is no method to execute this <code>Query query</code> and get result.<br>
  I know, that I can count records using   </p>
  
  <pre><code>String queryString = "SELECT * FROM my_table";  
  Query query = entityManager.createNativeQuery(queryString); 
  query.getResultList().size();  
  </code></pre>
  
  <p>so question, is query with <code>Count(*)</code> more performance, and if <code>yes</code>, then how can I execute query with <code>Count(*)</code>?</p>