Possible Duplicate:
Example of using CURRENT_DATE in JPA query
I am trying to add a query to my repository to compare a date stored in the db against the current date.
My query is like this:
@Query("Select c from Customer c where c.terminated != 1 or c.terminationDate > <currentDate>")
public List<Customer> getTerminatedCustomers();
What can I insert for <currentDate>
?
If everything fails I could add a parameter to the method and pass the current date to the query like this. But I would prefer a more elegant solution, if possible.
This question is actually a duplicate of this one. According to the Java Persistence API specification section 4.6.17.2.3 there are predefined functions CURRENT_DATE
, CURRENT_TIME
and CURRENT_TIMESTAMP
. So the query would have to be defined as
select c from Customer c where c.terminated != 1 or c.terminationDate > CURRENT_DATE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With