My domain class is like this:
Class Account {
String accountNo
...
def beforeUpdate = {
new AuditTrial(eventName:"update").save()
}
}
In my application there is a block-level transaction as follows:
def updateAccount = {
Account.withTransaction { status ->
def source = Account.get(params.from)
def dest = Account.get(params.to)
def amount = params.amount.toInteger()
if(source.active) {
source.balance -= amount
if(dest.active) {
dest.amount += amount
} else {
status.setRollbackOnly()
}
}
}
}
When I try to invoke this updateAccount
method, it gives a stack overflow exception. It seems to be that the beforeUpdate
method has been called recursively.
expect your worth suggestions to overcome this problem