我正在编写postgresql查询。当我运行查询
时 "reservatio0_.DATE_ >(NOW() - '60 MINUTES'::INTERVAL)
"在pgAdmin上它工作正常,但在java中我得到了
QuerySyntaxException,意外令牌:: bla bla
如果我运行此代码
List<Reservation> list = em.createQuery(
"select r " +
"from Reservation r " +
"where r.group.id=:groupName " +
" and r.date >(NOW() - '60 MINUTES'::INTERVAL) " +
"order by r.date asc")
.setParameter("groupName", groupName)
.setParameter("number", number)
.setMaxResults(1)
.getResultList();
答案 0 :(得分:1)
尝试用:
替换冒号运算符(\\:
)
这将逃脱这个特殊的角色..
答案 1 :(得分:0)
and r.date >(NOW() - interval '60 minutes')