Using Grails 2.3.9
I am currently trying to test the optimistic locking in Grails. The documentation says,
When you perform updates Hibernate will automatically check the version property against the version column in the database and if they differ will throw a StaleObjectException
In the integration test, I have something like:
def existingGroup = new Group("Group")
.save(flush: true, failOnError: true)
def groupA = Group.get(existingGroup.id)
def groupB = Group.get(existingGroup.id)
groupA.name = "Group A"
groupA.save(failOnError: true, flush: true)
groupB.name = "Group B"
groupB.save(failOnError: true, flush: true)
The exception is, however, never thrown. So, I guess, I'm doing something wrong with the session/flushing. But all permutations (using flush and not) on that had no change. I would like to see that this exception is thrown.
I also tried resetting the version to 0, without success (groupB saved as usually).
Am I doing something wrong?