title: On the surface, JPA Criteria Queries are a huge step back from Hibernate Criteria Queries. Is this really the case?
body: <p>How could such a colossal step back be justified!?!  Am I missing something?  The readability of the entity manager version is just awful.</p>
  
  <p>session().createCriteria(Entity.class).add(Restrictions.eq("id"), id).uniqueResult();</p>
  
  <p>versus</p>
  
  <pre><code>EntityManager em = getEntityManager();
  try {
      CriteriaBuilder cb = em.getCriteriaBuilder();
      CriteriaQuery&lt;Transaction&gt; cq = cb.createQuery(Transaction.class);
      Metamodel m = em.getMetamodel();
      EntityType&lt;Transaction&gt; Transaction_ = m.entity(Transaction.class);
      Root&lt;Transaction&gt; transaction = cq.from(Transaction.class);
  
      // Error here. cannot find symbol. symbol: variable creationDate
      cq.where(cb.between(transaction.get(Transaction_.creationDate), startDate, endDate));
  
      // I also tried this:
      // cq.where(cb.between(Transaction_.getDeclaredSingularAttribute("creationDate"), startDate, endDate));
  
      List&lt;Transaction&gt; result = em.createQuery(cq).getResultList();
      return result;
  } finally {
      em.close();
  }
  </code></pre>