Apparently the situation is this: with the working class the ApplicationServer checks the optimistic locking field before trying to write, finds that the field is modified, updates the cache and throws a javax.persistence.OptimisticLockException.
With the non-working class the ApplicationServer does not check the optimistic locking field, but tries to write instantly. The call to EntityManager.merge succeeds. However, upon committing it seems that the optimistic locking condition is finally detected. In my logfile I can see an internal oracle.toplink.essentials.exceptions.OptimisticLockException, but the cache is not updated and instead of a javax.persistence.OptimisticLockException a javax.transaction.TransactionRollbackException is thrown to my application. On the next access I am getting stale data, because the cache was never updated.
Ulrich
[Message sent by forum member 'ulim' (ulim)]
http://forums.java.net/jive/thread.jspa?messageID=242318