I'm in need of getting count of deleted rows by Spring Repository custom query (i'm implementing basic external lock mechanism for application and is limited to MySQL database only). How can i achieve that?
Create a repository method with the @Modifying
annotation as described here:
@Modifying
@Query("delete from data where createdAt < ?1")
int retainDataBefore(Date retainDate);
Return value gives you the count of deleted rows.
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