users@glassfish.java.net

Re: Optimistic locking : unnecessary update statements generated

From: <glassfish_at_javadesktop.org>
Date: Thu, 05 Apr 2007 08:43:34 PDT

You must be using the WRITE locking mode which requires an update to the version field of any locked object. You could switch to the READ mode which will not perform version updates on non-changed objects but will provide similar protection.
Please note that the EntityManager.lock() call is note required to have changed objects participate in OptimisticLocking. Changed objects will have their version fields updated automatically. The 'lock()' call is used to enlist objects that may not change in this transaction.

If you are seeing a version update for objects locked with lock mode WRITE on every flush please file a bug as the version field should only be updated once per transaction.
--Gordon
[Message sent by forum member 'gyorke' (gyorke)]

http://forums.java.net/jive/thread.jspa?messageID=211297