Reputation: 2098
I'm writing postgresql query. When I run the query
"reservatio0_.DATE_ >(NOW() - '60 MINUTES'::INTERVAL)
" on pgAdmin it works fine, but in java I get
QuerySyntaxException, unexpected token: : bla bla
if I run this code
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();
Upvotes: 0
Views: 1380
Reputation: 9941
IIrc you have to put the interval in front of the amount, like this:
and r.date >(NOW() - interval '60 minutes')
Upvotes: 0
Reputation: 2449
try to replace your colon operator (:
) with \\:
that would escape this special character..
Upvotes: 2