I want to delete records which are one day older , I am using SQL query in Spring data JPA as below:
@Query(value = "delete from tableName data where data.CREATION_DATE < TRUNC(SYSDATE) - 1", nativeQuery = true)
void deleteRecordsOlderThanYesterday();
I am getting exception as:
Caused by: org.springframework.orm.jpa.JpaSystemException: Could not extract result set metadata Caused by: org.hibernate.HibernateException: Could not extract result set metadata
Caused by: java.sql.SQLSyntaxErrorException: ORA-00900: invalid SQL statement
What is wrong with above code or is there any other way to do it in HQL?
Please let me know.