On 10/31/07, Mario Ivankovits <[EMAIL PROTECTED]> wrote:
> Hi!
> >> Is it possible to describe "full attribute optimistic locking" in a couple 
> >> of sentences, or should I look at the cayenne docs? (A quick google didn't 
> >> show anything obviously related..)
> >>
> >
> > Sure.   Instead of creating and locking on a special version field,
> > lock on all fields (or all that are important).    Assuming table
> > foo[w,x,y,z], use "update foo set x=1, y=1 where w=old_w, x=old_x,
> > y=old_y, z=old_z"
> >
> Beware, (especially with the "or all that are important" thing) this
> might allow to become your entity out of sync. Means, your entity is a
> mixture of
> different updates which you are not aware of then.
> Using all properties of the version column (which might be more
> performant) is the only option to prevent this.

Well, we're getting a bit off topic, but there's nothing to beware of
here.   If you lock on all columns which can change, then it will
always work.   If a column cannot change, then there's no need to lock
on it.   If in doubt, lock on them all -- it's the safest thing to do
if there's no performance issues. F.A.O.L. has its downsides (requires
caching of old attributes), but it has its upsides too -- works with
any database and any database table without modification of schema,
assuming all columns support equality operations.

Reply via email to