Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JPA date arithmetics ?

843830May 21 2010 — edited Feb 11 2011
I 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 11 2011
Added on May 21 2010
4 comments
1,125 views