HQL:仅在2个月前过滤查询 [英] HQL : filtering query only 2 month before
本文介绍了HQL:仅在2个月前过滤查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想问一下,如何将此postgres查询转换为HQL:
i want to ask, how to convert this postgres query to HQL :
select * from transactions
其中 trans_time> = date () - 60 *间隔'1天')
select * from transactions where trans_time >= date(now() - 60 * interval '1 day')
如何将该查询(粗体类型)转换为hql?
how to convert that query(in bold type) to hql?
谢谢
推荐答案
Calendar minDate = Calendar.getInstance();
minDate.add(Calendar.DATE, -60);
String hql = "select t from Transaction t where t.transactionTime >= :minDate";
List<Transaction> result = session.createQuery(hql)
.setTimestamp("minDate", cal.getTime())
.list();
这篇关于HQL:仅在2个月前过滤查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文