Originally posted by Amandeep Singh: i understand that, if you use LockModeType.READ, then your application acquires a READ lock on an entity. Then neither of issues as Dirty Read or Phantom Read will take place.
Whereas for LockModeType.Write, no update or delete operation is allowed on the entity.
1) the persistence provider acquires a LockModeType.Read, then does it allows update or delete operation. If not, so what is the difference between LockModeType.Read and LockModeType.Write.
to perform a update or delete, first you should have a read access. since the record is already read lock you(other transaction) cant update or delete the record
2) the persistence provider acquires a LockModeType.Write, then does it allows Dirty Read or Phantom Read. If not, so what is the difference between LockModeType.Read and LockModeType.Write.
READ: Other transactions may concurrently read the object, but cannot
concurrently update it.
WRITE: Other transactions cannot concurrently read or write the object. When a
transaction is committed that holds WRITE locks on any entites, those entites will
have their version incremented even if the entities themselves did not change in the
From Mastering EJB 3.0 :-
Read Locks are nonexclusive, in that any number of concurrent transactions can acquire a read lock. In comparison, write locks are exclusive - only one transaction can hold a write lock at any time.
subject: Difference between Read Lock and Write Lock