How to fix StaleObjectStateException with JPA and Hibernate
Controller Logic: def updateObject() { Object o = Object.get(params.id as Long) o.otherObjects.clear() objectDataService.saveObject(o.id) OtherObject newObject = new OtherObject; o.addToOtherObjects(newObject) objectDataService.saveObject(o.id) } ServiceLogic def saveObject(long profileId) { o.save(flush:true) } what happens in 90% of the cases this will just work. problems ERROR errors.GrailsExceptionResolver - StaleObjectStateException occurred when processing request: [GET] /controller/updateObject - parameters: stuff[]: data Row was updated or deleted by another transaction (or unsaved