In Grails, is there a way to ignore optimistic locking for 1 save and use it in another? I have an integration service that updates some meta data to a domain instance once a while, and I don't want that it locks a form. Can I e.g. change the object's version property on fly or ignore raising the version number during save process? Or is there a way to ignore an OptimisticLockingFailureException during save process? I would like to disable optimistic locking check in that 1 part of code only!
I have tried following with no luck - It always throws "The instance was updated by another user while you were editing":
// Validate before optimistic locking hacking - Save is done with validate: false
if (filledForm && filledForm.validate() == true) {
// Do not update version number (optimistic locking) on save
if(filledForm.version > 0){
filledForm.version = filledForm.version - 1
}
filledForm.save(validate:false, deepValidate: false, flush:true, failOnError:false)
}
I'm using Grails 2.3.8 with MongoDB-plugin 3.0.0