(Quick Reference)
executeUpdate
Purpose
Allows updating a database with
DML-style operationExamples
Account.executeUpdate("delete Book b where b.pages > 100")
Account.executeUpdate("delete Book b where b.title like ?", ['Groovy In Action'])
Account.executeUpdate("delete Book b where b.author=?", [Author.get(1)])
Account.executeUpdate("update Book b set b.title='Groovy In Action' where b.title='GINA'")
Description
GORM does not provide a
deleteAll
method as deleting data is to be done with caution. If you really need to delete data you can use
executeUpdate
. The basic syntax is:
Book.executeUpdate( String query )
Book.executeUpdate( String query, Collection positionalParams )
Parameters:
query
- An HQL query with DML-style operations
positionalParams
- A List of parameters for a positional parameterized HQL query