title: Grails Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)
body: <p>This isn't actual code but code to just recreate the error i am trying to understand. </p>
  
  <pre><code>    //if this question has options
      if(question.options){
  
          //deleting all the options first
          def l = []
          l += question.options
  
          l.each { option -&gt;
              question.removeFromOptions(option)
              option.delete(flush: true)
              }
  
      }
  
  
  
      //saving new options from the form
      if(params.options){
  
          for(po in params.options){
  
              question.addToOptions(new QuestionOptionSurvey(optionText: po))
  
          }
  
      }
  </code></pre>
  
  <p>So, the first section deletes existing options belonging to the question and the second part adds the new options to the question. Please note that this chunk belongs to a service method. So, the error thrown is "Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)". I know there are already posts regarding this issue but even after reading the docs and not being able to make sense i have come here for simpler explanation on the reason for this error. Why does grails or hibernate prevent me from first deleting options and then updating new options? i appreciate any help.</p>