Optimistic locking seems not to work

From: Jan Lendholt (jlendhol..otmail.com)
Date: Sat Jul 28 2007 - 06:22:18 EDT

  • Next message: Michael Gentry: "Re: Optimistic locking seems not to work"

    Hey Folks,

    I'm using Cayenne now for 2 weeks and I'm still in my playground-phase to
    check out the whole functionality of this leight-weighted, but yet easy to
    use framework.

    Ok, here's my problem:

    I created a table storing a custimer id (KID), a name (name) and a status
    (status).
    This table has one recordset with kid=2133.

    Now I start up my (Swing) application and create two instances of this
    application.
    Ok, I have got two buttons - one button is getting the object "Kunde" (Kunde
    = Customer, german) and the other button modifies via the setter setName and
    send the modification with commitChanges().

    Well, now I am quite astonished: When I load my object in instance one then
    load my object in instance two and afterwards hit den button in instance 1
    to modify & save the changes Cayenne sets an update:

    INFO QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID = ? AND NAME =
    ?
    INFO QueryLogger: [bind: 'Test 1', 2133, 'Test']

    This is correct and works as expected.

    Now I hit the Modify & Save button in stance 2. i would expect that the
    statement would look like:

    INFO QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID = ? AND NAME =
    ?
    INFO QueryLogger: [bind: 'Test 2', 2133, 'Test']

    And because no row is affected/the row has been modified in the meantime I
    would cayenne expect to raise an exception.

    But instead I get the following queries:

    INFO QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID = ? AND NAME =
    ?
    INFO QueryLogger: [bind: 'Test 2', 2133, 'Test 1']

    Where did cayenne get the new value for name which has been set just a few
    seconds before? Shouldn't cayene raise an excepption?

    In the modeler I checked the optimist locking checkbox and checked the
    name-attribute to be used for optimistic locking and all references.

    Maybe one could help me, I really do not understand when cayenne is about to
    raise an exception for optimist locked tables.

    Thanks in advance & best regards form Hamburg/Germany,

    Jan

    _________________________________________________________________
    Die neue MSN Suche Toolbar mit Windows-Desktopsuche. Suchen Sie gleichzeitig
    im Web, Ihren E-Mails und auf Ihrem PC! Jetzt neu! http://desktop.msn.de/
    Jetzt gratis downloaden!



    This archive was generated by hypermail 2.0.0 : Sat Jul 28 2007 - 06:22:55 EDT