I want to delete the rows which are older than 2 years. In SQL I do it like this:
DELETE FROM table WHERE creation_date < (current_date - interval '2 year');
Now I want to do the same for my JPA Repository in Java with the JPQL. In JPQL I get an error because interval is not known and the "-"(minus) is not correct.
JPQL Query
@Query("DELETE FROM table t WHERE t.creation_date < (current_date - interval '2 year')")
I would appreciate any suggestion.