问题
i want to ask, how to convert this postgres query to HQL :
select * from transactions where trans_time >= date(now() - 60 * interval '1 day')
how to convert that query(in bold type) to hql?
Thanks
回答1:
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();
来源:https://stackoverflow.com/questions/10780471/hql-filtering-query-only-2-month-before