String htStart = this.Start;// 开始时间
String htEnd = this.Endtime;//结束时间
s = "from ActingAdminUser as model where model.regtime >= "+htStart+" and <= "+htEnd+" order by model.uid";
从页面获取用户输入的开始和结束时间,然后用hql查询,不懂哪里出问题了,就是没数据,没异常。时格式都是2009-05-02这样的,我的hql语句出错了吗?

解决方案 »

  1.   

    between ... and....不行吗?
      

  2.   

    建议楼主用between ...and...在数据库的老一点的版本中是不支持and的
      

  3.   

    hql不支持between  and 的吧
      

  4.   

    <query name="GetDocsForView">
       <![CDATA[
    select A 
    from com.po.TDocument A where 1=1 
    and A.createdDate between :fDate and :eDate 
    and A.docId in (:ids) 
       ]]>
    </query>在查询的时候最好别用字符串拼接,HQL有对象封装功能。
      

  5.   


    Session session = super.getSession();
    Query q = session.createQuery("from ActingAdminUser where  time between '" + begindate + "' and '" + enddate + "'");经常用这个。
      

  6.   

    报异常
    java.lang.NoSuchMethodError: org.hibernate.hql.antlr.HqlBaseParser.recover(Lantlr/RecognitionException;Lantlr/collections/impl/BitSet;)V
      

  7.   

    原来是yyyy年xx月xx日 yyyy-xx-xx不能比较