BeforeUpdate afterUpdate

We have beforeUpdateOf * (where * is some field?)

and one more question:

def beforeUpdate = { ("in beforeUpdate" + this.status)}

def afterUpdate = { ("in afterUpdate" + this.status)}

This gives the same status. Although the actual state of the object (this) is updated from x to y


source to share

2 answers

There is no event when the property changes, but you can add an explicit setter that does something:

class MyDomainClass {
   String status

   void setStatus(String status) {
      this.status = status
      // do something based on changed value


You see the same value in beforeUpdate

and afterUpdate

, because these callbacks are for Hibernate persisting the changed values ​​to the database. It would be unusual for the value to change between the time Hibernate was started and the update completed.

If you are looking for the original value from the database, it is available at



You might want to take a look at the Grails audit plugins: Audit Log and Trail Audit



All Articles