How do you bulk delete records in Grails/GORM?

前端 未结 3 541
一生所求
一生所求 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条回答
  •  猫巷女王i
    2021-02-05 05:28

    From the User Guide about deleting objects:

    Note that Grails does not supply a deleteAll method as deleting data is discouraged and can often be avoided through boolean flags/logic.

    If you really need to batch delete data you can use the executeUpdate method to do batch DML statements:

    Customer.executeUpdate("delete Customer c where c.name = :oldName", [oldName:"Fred"])
    

提交回复
热议问题