java - can OptimisticLockException occur if app srv Isolation level is set to READ COMMITTED? -
i using websphere application server 7.0.0.0.9 ;openjpa 1.2.3-snapshot'. have set property of jdbc data source webspheredefaultisolationlevel=2 (read committed). have question because understanding optimasticlockexception occurs if there race commit same row multiple thread. think situation should never occur if isolation level app server set read committed.
this exception getting..
<openjpa-1.2.3-snapshot-r422266:907835 fatal store error> org.apache.openjpa.persistence.optimisticlockexception: optimistic lock violation detected when flushing object instance
i have question because understanding
optimisticlockexception
occurs if there race commit same row multiple thread.
yes, optimisticlockexception
thrown if version
attribute of entity higher (i.e. has been modified transaction) @ commit time when read. illustrated figure below (borrowed jpa 2.0 concurrency , locking):
but think situation should never occur if isolation level app server set read committed.
why? when using read committed isolation level, non-repeatable reads may occur but:
- this won't affect in memory representation of data (
e1
in above example) - most of time, don't re-read data
- and if (and perform non-repeatable read), entity might still modified thread before commit changes.
to sum up, read committed won't prevent optimisticlockexception
.
Comments
Post a Comment