Delete records from more than 1 year ago

前端 未结 4 657
说谎
说谎 2021-01-18 02:26

I\'m saving twitter tweets in my database with spring JPA Repositories. The date of the tweet is saved as Datetime in the MySQL db. Now I want to delete all tweets that are

4条回答
  •  爱一瞬间的悲伤
    2021-01-18 02:59

    Compute the current time minus one year in Java, and then use the follwoing query:

    DELETE FROM Tweetpost t WHERE t.createdAt < :nowMinusOneYear
    

提交回复
热议问题