Total cost: $4.7 with uniforms: 1 version: 0
2016-10-29T20:33:45.601-0400|Info: employee :1 add a uniform: 2 version: 1
2016-10-29T20:33:45.678-0400|Info: Total cost: $9.4 with uniforms: 1 version: 1
2016-10-29T20:33:45.699-0400|Warning: Local Exception Stack:
Exception [EclipseLink-5006] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.OptimisticLockException
Exception Description: The object [Employee id: 1 name: Sarah] cannot be updated because it has changed or been deleted since it was last read.
Class> examples.model.Employee Primary Key> 1
at org.eclipse.persistence.exceptions.OptimisticLockException.objectChangedSinceLastReadWhenUpdating......
But as I check on the database table, employee, I saw this:
id | name | cost | version
-------------------------------
1 sarah 4.7 2
My question is : the second calculateCleanCost transaction with total $9.4 is rolled back as the version number is updated from 0 to 1.
But why in the database , the version is 2?
It makes sense to me that the cost is still $4.7 as the second transaction is rolled back..