With spring boot, I want to delete data greater than 48 hours in the
database with a sql query.
I want to delete data in database more than 48 hours.
DELETE FROM schedule WHERE date_time < NOW() - INTERVAL 48 HOUR;
This query works fine in mysql, but I want to do it in spring boot.
@Query("DELETE FROM schedule WHERE date_time < NOW() - INTERVAL 48 HOUR")
i do it this way but i get error (‘(‘, or expected, got ’48’)
2
Answers
i think this one will be helpful,
Or you can use hibernate query language(HQL) instead of native query