请问在hibernate 里按时间查询是不是很麻烦啊  我在MYSQL里是DATE类型 写HQL语句怎么弄都是错
求指教啊我的代码是
str="from LiveApplication c where c.appLiveInfo.appTime=:apptimes" +
"and c.name='"+name+"'";……
Query q=(Query)s.createQuery(str).setTimestamp("apptimes", apptime);
List<LiveApplication> cs=q.list();

解决方案 »

  1.   

    String HQL ="from LiveApplication c where c.appLiveInfo.appTime=:apptimes" +
    "and c.name:name";
    query.setParameter("apptimes", "时间");
    query.setParameter("name", "名称");
      

  2.   

    恩,用二楼的方法可以了,多谢了,另外也可以用
    String hql="from Users u where u.downloadTime BETWEEN '"+startTime+"' and '"+endTime+"' ORDER BY u.downloadTime";
    这种,这种我也试过。