[jboss-user] [EJB 3.0] - Re: EntityManager.lock() issues

mteira do-not-reply at jboss.com
Wed Aug 23 05:16:20 EDT 2006


In different words, what I'm looking for is the way to apply a pessimistic locking approach here. 
I was googling and found some not clear enough signs that pessimistic locking is not supported in JPA entities. Is this true?

The approach I was trying to use:
 
 AEntity a = manager.find(AEntity.class, aId); 
 manager.lock(a, LockModeType.READ);

I think now it's not the way to go, because it's not atomic: Different competing threads could adquire an entity representing that database row before one of then reaches the lock.

So, is there any way to force the EntityManager.find to use a 'select for update' clause to make its job?

Regards.
 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3966906#3966906

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3966906



More information about the jboss-user mailing list