BeforeUpdate afterUpdate
We have beforeUpdateOf * (where * is some field?)
and one more question:
def beforeUpdate = {log.info ("in beforeUpdate" + this.status)}
def afterUpdate = {log.info ("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
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 http://grails.org/doc/latest/ref/Domain%20Classes/getPersistentValue.html
source to share