RE: Optimistic Locking Bug?

From: Gentry, Michael \(Contractor\) ("Gentry,)
Date: Wed May 11 2005 - 16:24:01 EDT

  • Next message: Mike Kienenberger: "Re: Optimistic Locking Bug?"

    I think part of the confusion is this:

    DataNode.runBatchUpdateAsIndividualQueries(...) calls:
      QueryLogger.logQueryParameters(...) which is getting passed the values of:
        BatchQuery.getValuesForUpdateParameters() which looks like:

        public List getValuesForUpdateParameters() {
            int len = getDbAttributes().size();
            List values = new ArrayList(len);
            for (int I = 0; I < len; i++) {
                values.add(getObject(i));
            }
            return values;
        }

    This method is putting together the list of attributes to log (the binding attributes), but it doesn't exclude the null parameters in the log. Because of this, the UPDATE statement that is logged doesn't agree with the binding parameters which are logged, which is confusing (well, OK, it confused me).

    I'm still having optimistic locking issues, though ... Bleh.

    /dev/mrg

    -----Original Message-----
    From: Mike Kienenberger [mailto:mkienen..laska.net]
    Sent: Tuesday, May 10, 2005 3:45 PM
    To: cayenne-deve..bjectstyle.org
    Subject: Re: Optimistic Locking Bug?

    "Michael Gentry (Yes, I'm a Contractor)" <michael_gentr..anniemae.com>
    wrote:
    >
    > Iım getting an optimistic locking failure when trying to update a record.
    > Here is a portion of the log with the problem highlighted (and reformatted
    > to be easier to read, hopefully):
    >
    > 14:26:55,115 INFO QueryLogger:315 -
    > UPDATE LoanCommitment
    > SET identifier = ?,
    > commitmentOpenState = ?
    > WHERE identifier = ? AND
    > comments IS NULL AND
    > commitmentOpenState = ? AND
    > commitmentPeriod = ?
    > AND createDate = ? ...
    >
    > 14:26:55,196 INFO QueryLogger:337 -
    > [bind: < 00 00 00 00 00 00 00 22 59 2D F7 52 >,
    > [CREATED [DB=1]],
    > < 00 00 00 00 00 00 00 22 59 2D F7 52 >,
    > NULL,
    > [SUBMITTED [DB=2]],
    > 30, ...
    >
    >
    > It seems to me that if it is going to produce ³comments IS NULL² as part
    of
    > the prepared statement, it shouldnıt try to do a bind parameter, too. It
    is
    > trying to bind the NULL to the commitmentOpenState, when the original
    value
    > was a 2, so it is failing with a locking exception.

    If that's really the case, it's pretty strange.

    org.objectstyle.cayenne.access.trans.UpdateBatchQueryBuilder is where you
    want to look.

    createSqlString() is what generates the query text (once).
    bindParameters() is what binds the parameters (once for each batch data
    set).

    Maybe this is a problem specific to your particular DBAdaptor if it has
    custom handling for this.

    I see there's also a LOBUpdateBatchQueryBuilder, so maybe it's not behaving
    properly if you're triggering that instead.

    It'd probably be a good idea to state what version of Cayenne, and which
    DBAdaptor you're using.

    -Mike



    This archive was generated by hypermail 2.0.0 : Wed May 11 2005 - 16:24:06 EDT