How do you bulk delete records in Grails/GORM?

前端 未结 3 518
一生所求
一生所求 2021-02-05 05:15

I have a table which has records that need to be periodically cleared according to a set of criteria.

I was expecting that I could use the criteria builder to just delet

3条回答
  •  情深已故
    2021-02-05 05:44

    If you want to avoid HQL I'd suggest using GORM list(), delete() and Groovy's spread operator:

    def agencyList = Agency.createCriteria().list {
        eq("agency", "XXX")  
    }
    agencyList*.delete()
    

提交回复
热议问题