You seem to think that not having a version attribute automatically enables pessimistic locking? Or I have misread you - again! =) Let's just be clear, JPA 2.1, section 3.4.3:
No. Pessimistic locking (or not) is an API, a programatic choice. Optimistic locking is a cross-cutting, implicit choice (from the PoV of an application).
You both seem to think that I want to mix pessimistic and optimistic locking strategies...
Pessimistic locking is not a strategy, per-se. Its merely (usually) the lack of optimistic locking metadata and the application making a programatic choice to apply locking when and where (and if) it wants.
Our concern (or mine, anyway) has to do with the fact that you often want to do Counter counter = (Counter) session.load( Counter.class, 1 ); and then use that. So what happens when you try to apply persistence to a graph that uses that reference? Especially when you consider that counter might concretely be a Counter or it might concretely be a VersionedCounter. You have different behaviors and expectations.
|