title: JPA 2.1 CriteriaQuery between Date
body: <p>How can I use CriteriaQuery with BETWEEN clause in Date? I have tried this without success;</p>
  
  <p>the DAO method:</p>
  
  <pre><code>public List&lt;Registry&gt; listRegistry(Date init){
      List&lt;Registry&gt; registrys = null;
      try{
          Date currentDate = new Date();
          CriteriaBuilder cb = getEm().getCriteriaBuilder();
          CriteriaQuery&lt;Registry&gt; c = cb.createQuery(Registry.class);
          Root&lt;Registry&gt; registry= c.from(Registry.class);
  
          // get error here; "The method get(String) in the type Path&lt;Registry&gt; is not applicable for the arguments (String, Date, Date)"
          c.select(registry).where(cb.between(registry.get("dateEntry", init, currentDate)));
  
          registrys = getEm().createQuery(c).getResultList();
  
      }
      catch (NoResultException x) {
          //does nothing
      }
      return registrys;
  }
  </code></pre>
  
  <p>and the Entity Class Registry:</p>
  
  <pre><code>@Entity
  public class Registry {
  
  @GenericGenerator(name="gen",strategy="increment")
  @GeneratedValue(generator="gen")
  @Column(name = "id", unique = true, nullable = false, precision = 15, scale = 0)
  @Id
  private int id;
  
  private Date dateEntry;
  
  // getters and setters .....
  }
  </code></pre>
  
  <p>With these error  : "The method get(String) in the type Path is not applicable for the arguments (String, Date, Date)" ; How can I solve this?</p>