title: How to write a hql query for between clause for date range?
body: <p>I am writing a hql query which retrieve details of perticular vehicle between given dates, I have a method like this.</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      Session session = HibernateSession.getHibernateSession();
  
      // Starting Transaction
      Transaction transaction = session.beginTransaction();
      String hql = null;
      //ArrayList&lt;HistoryLatitudeBean&gt; vehicleHistoryList= new ArrayList&lt;HistoryLatitudeBean&gt;();
        try {
            DateFormat df = new SimpleDateFormat("yyyy/mm/dd");
            Date frmDate= df.parse("2014/01/01");
            Date toDate=df.parse("2014/09/01");
  
  
            hql= "from HistoryLatitudeBean where vehicleno=:vehicleno and rdate BETWEEN :frmdate and :todate";
            Query query =session.createQuery(hql);
              query.setParameter("vehicleno", 12);
              query.setParameter("frmdate", frmDate);
              query.setParameter("todate", toDate);
              List&lt;HistoryLatitudeBean&gt; groupList = (List&lt;HistoryLatitudeBean&gt;)query.list();
  
               for(HistoryLatitudeBean arr : groupList){
                   System.out.println(arr.getLat());   
                  }
  
  
               transaction.commit();
        }
        catch(Exception e){
            if (transaction!=null) transaction.rollback();
            e.printStackTrace();
        }
        finally{session.close();}
  } 
  </code></pre>
  
  <p>Here is my bean class</p>
  
  <pre><code>@Entity
  @Table(name="hlatlng")
  public class HistoryLatitudeBean {
  
  @Id
  @Column(name="vehicleno")
  private int vehicleno;
  @Column(name="lat")
  private String lat;
  @Column(name="lng")
  private String lng;
  @Column(name="status")
  private String status;
  @Column(name="rdate")
  private Date rdate;
  @Column(name="rtime")
  private Date rtime;
  
  //getter and setters
  
  }
  </code></pre>
  
  <p>The same query I am executing in mysql command line, I am getting 11 rows , but in java method I am getting no rows.</p>
  
  <p>In Mysql db I am trying query as</p>
  
  <p><code>select * from hlatlng where vehicleno=12 and rdate BETWEEN '2014/01/01' and '2014/09/01'</code></p>
  
  <p>I am not getting how to pass the date formate through hibernate. whats wrong in my above method can any one tell me . It realy helps me.</p>