jpa - Strange behavior for PESSIMISTIC_WRITE? -
i new jpa 2.0 locking, might missing something.
using netbeans, tried debug stateless session bean. tried switch between 2 threads examine concept:
em.lock(entity, lockmodetype.pessimistic_write); em.persist(entity); try { em.flush(); } catch (exception e) { system.out.println("already locked!"); } i let first process finish
em.flush();
(no exceptions). then, switched second process. surprisingly - paused after first line, , continued after first process exited function.
note: working expected lockmodetype.optimistic.
is normal behavior? missing something? here seems behave in different way.
thanks,
danny
it normal behavior. lock released in transaction commit/rollback , not happening consequence of calling em.flush().
Comments
Post a Comment