Re: One Transaction for select and update

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sun Feb 13 2005 - 23:38:39 EST

  • Next message: Julien Vignali: "Re: [s] best way for xml outputting"

    > does that mean I can't do this using Cayenne?

    Cayenne doesn't support pessimistic locking. Some people requested it
    in the past, so eventually it'll get implemented, but it is not high
    priority. It doesn't mean you can't do what you need within Cayenne
    environment... The question is how. You have a number of options:

    1. Use optimistic locking. (I would personally go with this one - I
    hate to lock the database from the application code)
    2. Write a stored procedure that does the update.
    3. If this is a PK, use custom PkGenerator.

    Andrus

    On Feb 13, 2005, at 10:58 PM, JR Ruggentaler wrote:
    > Andrus,
    > thanks! When you say "As PK generator operates at
    > the JDBC level you can do SELECT FOR UPDATE manually or even use an
    > updateable result set." does that mean I can't do this using Cayenne?
    > I tried using SQLTemplate() but it still possible to update
    > NEXT_ACCOUNT_ID from another connection between the SELECT FOR UPDATE
    > and UPDATE. Can you provide and example?
    >
    > J.R.
    > -----Original Message-----
    > From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    > Sent: Sunday, February 13, 2005 6:05 PM
    > To: cayenne-use..bjectstyle.org
    > Subject: Re: One Transaction for select and update
    >
    >
    > I guess what you are asking for is pessimistic locking (aka SELECT FOR
    > UPDATE). I am not sure that just wrapping both statements in a single
    > DB transaction (which would've been trivial to do with Spring or J2EE
    > external transactions) would solve it.
    >
    > If it is for PK generation purposes, it shouldn't be too hard to create
    > a PK generator to use your custom schema. As PK generator operates at
    > the JDBC level you can do SELECT FOR UPDATE manually or even use an
    > updateable result set.
    >
    > Andrus
    >
    >



    This archive was generated by hypermail 2.0.0 : Sun Feb 13 2005 - 23:38:43 EST