JPA date arithmetics ?
843830May 21 2010 — edited Feb 11 2011I need to select all rows, having a date >= yesterday. Something like this in native SQL:
SELECT * from mytable mt
WHERE mt.mydate >= SYSDATE - 1;
I saw that JPA has the CURRENT_DATE / TIMESTAMP/ TIME functions, so I tried writing a JPA named query like this :
SELECT mo from MyObject mo
WHERE mo.myDate >= CURRENT_DATE - 1;
but it doesn't work - obviously JPA doesn't work the same way as plain SQL does regarding the evaluation of a (DATE - Number) expression.
(I'm using Apache's openJPA v 1.0.4)
Any ideas what to do ?
Edited by: atopalov on May 21, 2010 5:48 AM