openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Prud'hommeaux <mprud...@apache.org>
Subject Re: pessimistic locking
Date Fri, 12 Jan 2007 20:06:34 GMT

I think you also want to set "openjpa.Optimistic" to "false". That  
will default to non-optimistic transactions.

Setting the other properties ("openjpa.LockManager",  
"openjpa.ReadLockLevel", "openjpa.WriteLockLevel") are probably  
unnecessary.



On Jan 12, 2007, at 11:56 AM, Ritika Maheshwari wrote:

> 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
View raw message