Hibernate 当前日期查询不工作HQL
在使用hibernate查询从数据库中检索今天之前的记录时,我遇到了一个问题 我的问题是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
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