"Fossies" - the Fresh Open Source Software Archive

Member "grails-core-5.2.4/grails-docs/src/test/resources/docs/ref/Domain Classes/executeUpdate.html" (14 Sep 2022, 61505 Bytes) of package /linux/www/grails-core-5.2.4.tar.gz:

Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the grails-core-5.2.4.tar.gz project site itself.

(Quick Reference)



Updates the database with DML-style operations


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=?",

Account.executeUpdate("update Book b set b.title='Groovy In Action'" +
                      "where b.title='GINA'")

Account.executeUpdate("update Book b set b.title=:newTitle " +
                      "where b.title=:oldTitle",
                      [newTitle: 'Groovy In Action', oldTitle: 'GINA'])


GORM does not provide a deleteAll method as deleting data must be done with caution. To delete data you can use executeUpdate. The basic syntax is:

Book.executeUpdate(String query)
Book.executeUpdate(String query, List positionalParams)
Book.executeUpdate(String query, Map namedParams)


  • query - An HQL query with DML-style operations

  • positionalParams - A List of parameters for a positional parameterized HQL query

  • namedParams - A Map of parameters for a named parameterized HQL query