0 Replies Latest reply on Jul 4, 2007 9:47 AM by Georges Berscheid

    Concurrency & Optimistic locking

    Georges Berscheid Newbie


      I have transaction T1 who's calling em.find() to retrieve and modify an entity E1.
      Is there any way to make em.find() in T2 wait to return entity E1 until T1 has committed the changes on E1.
      This is, knowing that T1 has started before T2.

      I want to prevent T2 from throwing an OptimisticLockException and to make it retry reading / writing E1 until no other transaction is active anymore.

      If I call em.lock(E1, LockModeType.READ) in T1 before T2 starts, will em.find() T2 throw an exception or will it wait until T1 has committed (or rolled back) before returning E1?

      Thanks a lot,