title: Using JPA/Hibernate Criteria to pull between a date
body: <p>I am trying to using the following code to pull a list of Experience objects from a <code>MySQL</code> table. Each experience has a from <code>datetime</code> column and a to <code>datetime</code> column and I only want to pull rows where todays date falls in between the from and to.</p>
  
  <p>I am using JPA 2.0 running off of Hibernate.</p>
  
  <pre><code>    Date currentDate = new Date();
      CriteriaBuilder builder = entityManager.getCriteriaBuilder();
      CriteriaQuery&lt;Experience&gt; query = builder.createQuery(Experience.class);
      Root&lt;Experience&gt; root = query.from(Experience.class);
      builder.between(currentDate, root.get("from"), root.get("to"));
      return entityManager.createQuery(query).getResultList();
  </code></pre>
  
  <p>My issue is that <code>builder.between()</code> obviously wont allow me to pass a Date object.</p>
  
  <p>Is there a better solution to my problem?</p>