title: How to count number of rows using JPA?
body: <p>I try to count number of rows using JPA.I want to use where clause 
  however I can't. </p>
  
  <pre><code>CriteriaBuilder qb = entityManager.getCriteriaBuilder();
  CriteriaQuery&lt;Long&gt; cq = qb.createQuery(Long.class);
  cq.select(qb.count(cq.from(MyEntity.class)));
  cq.where();  //how to write where clause 
  return entityManager.createQuery(cq).getSingleResult();
  </code></pre>
  
  <p>How can I set where clause forexample where age="45".
  Thanks in advance.</p>