Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: JPQL date function to add a time period to another date [closed]

SELECT x FROM SomeClass WHERE x.dateAtt BETWEEN CURRENT_DATE AND (CURRENT_DATE + 1 MONTH) 

In the above JPQL statement, SomeClass has a memebr dateAttr, which is a java.util.Date and has a @Temporal(javax.persistence.TemporalType.DATE) annotation.

I need a way to do the (CURRENT_DATE + 1 MONTH) bit - it is obviously wrong in its current state - but cannot find the doc with the date function for JPQL.

Can anyone point me in the direction of a doc that documents JPQL date functions (and also how to do this particular query)?

like image 617
bguiz Avatar asked May 18 '10 10:05

bguiz


1 Answers

Standard JPQL doesn't support such operations on dates. You will have to either use a native query or to do the computation on the Java side.

like image 97
Pascal Thivent Avatar answered Sep 22 '22 19:09

Pascal Thivent