openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ritika Maheshwari" <ritikams...@gmail.com>
Subject pessimistic locking
Date Fri, 12 Jan 2007 19:56:52 GMT
I have the following properties defined in my persistence.xml


<property name="openjpa.LockManager" value="pessimistic"/>

<property name="openjpa.ReadLockLevel" value="read"/>

<property name="openjpa.WriteLockLevel" value="write"/>

<property name="openjpa.LockTimeout" value="30000"/>

Even then the sql for the  query

em.createQuery("select object(o) from Neworders o where
o.no_w_id=:warehouseId and o.no_d_id=:districtId ")

does not have the With RS USE AND KEEP UPDATE LOCKS.

However if I make the following change

 OpenJPAQuery qry  = OpenJPAPersistence.cast(em.createQuery("select
object(o) from Neworders o where o.no_w_id=:warehouseId and
o.no_d_id=:districtId "));
           qry.setParameter("warehouseId",wareHouseId);
           qry.setParameter("districtId",distId);
           qry.getFetchPlan().setReadLockMode(LockModeType.READ);
        newOrdersSet = qry.getResultList();

Then the sql generated has the WITH RS USE AND KEEP UPDATE LOCKS CLAUSE.

So howcome JPA thinks it is in Optimistic mode even when the
persistence.xmlsets LockManager to pessimitic and when you set the
ReadLockMode on fetch
plan then it thinks you are in pessimistic mode.Is there some
misunderstanding or is this a bug.So essentially my question was that by
just specifying the properties of Lock Manager and ReadLockMode in the
persistence.xml all the queries generated by JPA should have had the Update
Clause.But that did not happen.I had to specifically set the ReadLockMode on
the Fetchplan of the query to make the Update clause appear.

ritika

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message