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