title: Grails: What makes sure that version check and update is atomic?
body: <p>The <code>update</code> action in Grails first checks for the version of the object to be updated and then updates it.
  What part of Grails ensures that the object isn't updated by another request during checking the version and updating the object? </p>
  
  <p><strong>Update:</strong></p>
  
  <p>Yes, hibernate will check for the version when savin the object and will throw an exception is optimistic locking fails. And I guess hibernate will make sure that the check+update is atomic, but...</p>
  
  <p>if you take a look at the grails generated update method, you'll find that grails first double-checks and then (from my point of view) isn't prepared to handle the exception. The chances that hibernate will throw an exception after the update method has already checked for the right version are small, but it seems possible to me.</p>
  
  <p>So wouldn't it be enough to try a save and catch the exception (if there is one)?</p>