<vendor>

I just wanted to point out (for those that don't know) that our CMP
engine provides such "searched" or "verified" updates automatically.
That is, by setting a per-entity property:

        ejb.cmp.optimisticConcurrencyBehavior

to either:

        VerifyModifiedFields

or:

        VerifyAllFields

we will issue an update that checks the before-transaction state of
the bean for either all CMP fields which were modified during the
trasnaction, or all CMP fields.  That is, we do the:

> > >     update T set X = newX, Y = newY, Z = newZ
> > >         where K = theK and X = oldX and Y = oldY and Z = oldZ

in our CMP engine, automatically.

For those who followed my previous posting on optimistic concurrency,
and how not doing checked updates can quickly corrupt your database,
this is how we avoid this nasty little EJB problem.

</vendor>

-jkw

Evan Ireland wrote:
>
> Sachin Hardas wrote:
> >
> > Evan,
> > We already do something of that sort. I don't know which is more efficient.
> > When an update is issued, we fetch the record from the database and compare it with
> > the original state we have with us.
>
> There is a small window between your select and update in which time
> the underlying data can be changed. I suggest the modified update syntax
> as it doesn't have any 'windows' where problems can arise.
>
> > A rollback is done if the states don't match.
> >
> > Thank you
> > Regards
> > Sachin
> >
> > Evan Ireland wrote:
> >
> > > Sachin Hardas wrote:
> > > >
> > > > Kristofer,
> > > > The solution you suggested would work only if you can modify the database.
> > > > We are not so lucky and cannot in any way update the database schema.
> > >
> > > Say you have table T, key column K, and data columns X, Y and Z. In your
> > > entity bean for T, save the original values of X, Y and Z. When you issue
> > > an update, use SQL of the form:
> > >
> > >     update T set X = newX, Y = newY, Z = newZ
> > >         where K = theK and X = oldX and Y = oldY and Z = oldZ
> > >
> > > Check the row count for this update. If it is zero, then rollback the
> > > transaction.
> > > ________________________________________________________________________________
> > >
> > > Evan Ireland              Sybase EAServer Engineering        [EMAIL PROTECTED]
> > >                             Wellington, New Zealand               +64 4 934-5856
> > >
> > > ===========================================================================
> > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> > > of the message "signoff EJB-INTEREST".  For general help, send email to
> > > [EMAIL PROTECTED] and include in the body of the message "help".
> >
> > ===========================================================================
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> > of the message "signoff EJB-INTEREST".  For general help, send email to
> > [EMAIL PROTECTED] and include in the body of the message "help".
>
> --
> ________________________________________________________________________________
>
> Evan Ireland              Sybase EAServer Engineering        [EMAIL PROTECTED]
>                             Wellington, New Zealand               +64 4 934-5856
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to