Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate 当前日期查询不工作HQL_Hibernate_Hql - Fatal编程技术网

Hibernate 当前日期查询不工作HQL

Hibernate 当前日期查询不工作HQL,hibernate,hql,Hibernate,Hql,在使用hibernate查询从数据库中检索今天之前的记录时,我遇到了一个问题 我的问题是 Query q = getSession().createQuery("FROM News n where n.to_published_date<= current_date order by n.to_published_date desc"); return q.list(); Query q=getSession().createQuery(“FRO

在使用hibernate查询从数据库中检索今天之前的记录时,我遇到了一个问题

我的问题是

Query q = getSession().createQuery("FROM News n where n.to_published_date<= 
          current_date order by n.to_published_date desc");
          return q.list();

Query q=getSession().createQuery(“FROM News n where n.to_published_date您可以尝试如下所示的方法吗?”

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String frmDate = format.parse(current_date);

Query q = getSession().createQuery("FROM News n where n.to_published_date<= :frmDate order by n.to_published_date desc")
                      .setTimestamp("frmDate ", current_date);
return q.list();
SimpleDateFormat格式=新的SimpleDateFormat(“yyyy-MM-dd HH:MM:ss”);
字符串frmDate=format.parse(当前_日期);

Query q=getSession().createQuery(“从新闻n哪里n.to_发布日期在今天的日期之前将为您提供所有信息,不是吗?您使用的
不适用于我,我需要当前时间5/27/2017 1:19:11之前的所有记录PM@N00bPr0grammer