Hi S.D.,
Current JPA spec does not define any portable mechanism to obtain pessimistic locks. LockModeType.READ (or LockModeType.WRITE) are typically implemented using optimistic strategy - that is using a version column. You will have to use vendor specific features. For example here is a reference to toplink specific way to obtain a pessimistic lock.
-Mitesh
glassfish@javadesktop.org wrote:
I know the JPA spec. doesn't define any behaviour for pessimistic locking but looking around I have read that TopLink, Hibernate and Kodo do support it.
From what I have seen the following is the appropriate way to do it and I would like to verify this.
em.lock(
em.getReference( x.class, x.getID() ),
LockModeType.READ ); // Not forcing version increment.
-- do some stuff --
x = em.find( x.class, x.getID );
After doing the find I can assume that I have a serializable isolation on x?
Thanks, S.D.
[Message sent by forum member 'sdoyle' (sdoyle)]
http://forums.java.net/jive/thread.jspa?messageID=241093
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net