I understand that optimistic locking compares the the version number in the managed entity to the one in the database. After the lock(write) previously called, the version is forced in the entity from n to n+1. So whehn flushing, the current version is n+1, not n.
If it were not for the lock(write) i agree is would be still n.
I am wrong?
[Message sent by forum member 'vladbalan' (vladbalan)]
http://forums.java.net/jive/thread.jspa?messageID=316852