如何在休眠中使用select查询在PostgreSQL中使用age()
函数来查找日期差异?
String sql="select ref_no,forward_to,strdate from forward_dtls where has_forwarded='0' and status='NotClosed' and forward_to=:fwdto and dated < now() - interval '5 days'";
Query queryy=session.createSQLQuery(sql);
queryy.setParameter("fwdto", username);
当我使用-
String sql="select ref_no,forward_to,strdate,age(now(),dated) from forward_dtls where has_forwarded='0' and status='NotClosed' and forward_to=:fwdto and dated < now() - interval '5 days'";
在休眠状态下,出现错误。在PostgreSQL中作为查询执行时,它运行良好。