Grails

Grails: handling StaleObjectStateException and making executeUpdate transactional

Recently I encountered a StaleObjectStateException which said “Row was updated or deleted by another transaction.” We were just updating multiple objects of the same domain inside a loop. So we used executeUpdate statement instead of myClass.save() method to update the records, which worked. ReserveAccount.executeUpdate(“update ReserveAccount set currentBalance=(:balance) where id=(:id)”, [balance: currBalance, id: reserveAccount.id]) Later we […]