You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Markus Reich <ma...@markusreich.at> on 2013/09/13 09:56:19 UTC
Optimistic Locking
Hi,
is there a possibility to disalbe optimistic locking for certain entites in
runtime?`
e.g. the user get's info that there's a optimistic locking problem, then
the user can force the commit ignoring the optimistic lock?
regards
Markus
Re: Optimistic Locking
Posted by Mike Kienenberger <mk...@gmail.com>.
Just be aware that it will affect all locking for your entire app.
You risk some other concurrent change going through without locking on
that column. It might be an acceptable tradeoff.
I don't think it'd be very difficult to modify Cayenne to read from
the individual entity itself to determine if you should be locking if
you wanted to pursue that change. getLockType() is only called a
couple of times in 3.0.2 -- once when creating a snapshot of values to
lock against, and once when creating the qualifiers from those
snapshots.
On Fri, Sep 13, 2013 at 4:33 PM, Markus Reich
<ma...@markusreich.at> wrote:
> perfect, thx!
>
>
> 2013/9/13 Mike Kienenberger <mk...@gmail.com>
>
>> On Fri, Sep 13, 2013 at 3:56 AM, Markus Reich
>> <ma...@markusreich.at> wrote:
>> > is there a possibility to disalbe optimistic locking for certain entites
>> in
>> > runtime?`
>> > e.g. the user get's info that there's a optimistic locking problem, then
>> > the user can force the commit ignoring the optimistic lock?
>>
>>
>> Looking at the source for 3.0.2, you can call
>> setDeclaredLockType(lockType) on the ObjEntity for your entity, where
>> lockType is one of the following:
>>
>> ObjEntity.LOCK_TYPE_NONE
>> ObjEntity.LOCK_TYPE_OPTIMISTIC
>>
>> This sets it for all entities of that type, however. I don't think
>> there's a way to set it for individual entities.
>>
>
>
>
> --
> *Markus Reich*
> Moosbach 28/2
> 6392 St. Jakob i.H.
> www.markusreich.at / www.meeximum.at
> markus.reich@markusreich.at
Re: Optimistic Locking
Posted by Markus Reich <ma...@markusreich.at>.
perfect, thx!
2013/9/13 Mike Kienenberger <mk...@gmail.com>
> On Fri, Sep 13, 2013 at 3:56 AM, Markus Reich
> <ma...@markusreich.at> wrote:
> > is there a possibility to disalbe optimistic locking for certain entites
> in
> > runtime?`
> > e.g. the user get's info that there's a optimistic locking problem, then
> > the user can force the commit ignoring the optimistic lock?
>
>
> Looking at the source for 3.0.2, you can call
> setDeclaredLockType(lockType) on the ObjEntity for your entity, where
> lockType is one of the following:
>
> ObjEntity.LOCK_TYPE_NONE
> ObjEntity.LOCK_TYPE_OPTIMISTIC
>
> This sets it for all entities of that type, however. I don't think
> there's a way to set it for individual entities.
>
--
*Markus Reich*
Moosbach 28/2
6392 St. Jakob i.H.
www.markusreich.at / www.meeximum.at
markus.reich@markusreich.at
Re: Optimistic Locking
Posted by John Huss <jo...@gmail.com>.
There is an "Optimistic Locking?" checkbox for each ObjEntity in
CayenneModeler that will turn it on or off.
If you want to do it ad-hoc at runtime you have to catch the exception and
then refetch the problem object (possibly repeatedly) and re-apply the
changes. It's a little messy.
On Fri, Sep 13, 2013 at 1:52 PM, Mike Kienenberger <mk...@gmail.com>wrote:
> On Fri, Sep 13, 2013 at 3:56 AM, Markus Reich
> <ma...@markusreich.at> wrote:
> > is there a possibility to disalbe optimistic locking for certain entites
> in
> > runtime?`
> > e.g. the user get's info that there's a optimistic locking problem, then
> > the user can force the commit ignoring the optimistic lock?
>
>
> Looking at the source for 3.0.2, you can call
> setDeclaredLockType(lockType) on the ObjEntity for your entity, where
> lockType is one of the following:
>
> ObjEntity.LOCK_TYPE_NONE
> ObjEntity.LOCK_TYPE_OPTIMISTIC
>
> This sets it for all entities of that type, however. I don't think
> there's a way to set it for individual entities.
>
Re: Optimistic Locking
Posted by Mike Kienenberger <mk...@gmail.com>.
On Fri, Sep 13, 2013 at 3:56 AM, Markus Reich
<ma...@markusreich.at> wrote:
> is there a possibility to disalbe optimistic locking for certain entites in
> runtime?`
> e.g. the user get's info that there's a optimistic locking problem, then
> the user can force the commit ignoring the optimistic lock?
Looking at the source for 3.0.2, you can call
setDeclaredLockType(lockType) on the ObjEntity for your entity, where
lockType is one of the following:
ObjEntity.LOCK_TYPE_NONE
ObjEntity.LOCK_TYPE_OPTIMISTIC
This sets it for all entities of that type, however. I don't think
there's a way to set it for individual entities.