Assume the following code in a Grails controller:
def action = {
ClassName o = ClassName.findByFoo(params.foo)
if (o) {
o.counter += 1
}
}
By default Grails uses optimistic locking via the version
column added by default to all GORM database tables. However, if a sufficiently large number of multiple concurrent requests are sent to this action the optimistic locking mechanism will break down with the following exception:
org.hibernate.StaleObjectStateException:
Row was updated or deleted by another transaction (or unsaved-value mapping was
incorrect): [ClassName#id]
For domain objects where a failed update/delete is totally non-critical I'd like to disable the locking mechanism, so that no StaleObjectStateException will be thrown thrown. How do I achieve that?