pessimistic-locking

sql rowlock on select statement

I have an ASP.Net webpage where the user selects a row for editing. I want to use the row lock on that row and once the user finishes the editing and updates another user can edit that row i.e. How can I use rowlock so that only one user can edit a row? Thank you ...

Pessimistic locking is not working with Query API

List esns=session.createQuery("from Pool e where e.status=:status "+ "order by uuid asc") .setString("status", "AVAILABLE") .setMaxResults(n) .setLockMode("e", LockMode.PESSIMISTIC_WRITE) .list(); I have the above que...

Two queries instead of one, when using LockOption.UPGRADE

I have two entities with one-directional OneToOne relationship. EAGER fetch type is specified. When I load parent entity by id, one sql inner join query is executed. This is right behavior. But when I specify LockOption.UPGRADE, the parent and child entities are loaded in two different queries instead of one. Why this happens? ...

JPA synchronizing entity accessors

Hello guys, Here's the setup: the entity class has the collection of other entities that is loaded lazily. The trick is, I need to perform some data-related work (for example, I want to calculate certain checksum with the elements of collection). The trick here is that I want to avoid at all costs the race conditions like: "someone ha...

Is LockModeType.PESSIMISTIC_WRITE sufficient for an UPSERT in JPA?

I've read this article on JPA concurrency, but either I am too thick or it is not explicit enough. I am looking to do a database-controlled atomic update-if-found-else-insert operation (an UPSERT). It looks to my poor slow brain that I can--within a transaction of course--run a named query with a lock mode of PESSIMISTIC_WRITE, see if ...

Does it make sense to use QueuedPessimisticEJBLock and optimistic-locking simultaneously?

I'm working on a J2EE application where the EntityBeans (EJB 2.1) are using the container configuration "Standard CMP 2.x EntityBean" which uses the locking-policy QueuedPessimisticEJBLock: <container-configuration> <container-name>Standard CMP 2.x EntityBean</container-name> ... <locking-policy>org.jboss.ejb.plu...