users@glassfish.java.net

Re: EntityManager's forced version update (lock(WRITE) + flush()) not atomi

From: <glassfish_at_javadesktop.org>
Date: Fri, 14 Nov 2008 15:16:20 PST

OK. I think I know where your confusion comes from...

If you update d1, there are 2 options for a JPA provider -
a) send an update to the database, then increment the version in the local copy (you need to have the n+1 in the version after commit, right?). In this case, the 'where' clause compares the existing version value.
b) increment the version in the local copy, then send an update to the database. In this case the 'where' clause compares the previous value of the version.

lock(WRITE) is similar to the update. If the provider still want to go through the option a), they just mark the instance as updated.

Does it make sense?
[Message sent by forum member 'mvatkina' (mvatkina)]

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