1 Reply Latest reply on Dec 7, 2004 8:03 AM by Alexey Loubyansky

    optimistic locking version column bug?

    Sven Baumgarten Newbie

      Hi,

      I use JBoss 4.0 Optimistic locking with optimistic-locking element content model "version column". If the version column is not a property of the entity bean jboss generates correct sql statement:

      UPDATE Person SET Name=?, Version=? WHERE ID=? AND Version=?
      param: i=1, type=VARCHAR, value=Test
      param: i=2, type=INTEGER, value=109
      param: i=3, type=INTEGER, value=1
      param: i=4, type=INTEGER, value=108

      If the version column is a property of the entity bean jboss generates correct sql statement but an incorrect parameter list:

      UPDATE Person SET Name=?, Version=? WHERE ID=? AND Version=?
      param: i=1, type=VARCHAR, value=Test

      some parameter (primary key and version no.) are missing! This happens only if the value of version column is not changed during the transaction. If I set a different value to the version column property like setVersion(10) the sql statement is generated correct. But this is a second strange behaviour. If a column is a version column jboss should override all changes and set it's own increased version value (109 in the example above).

      Can anybody explain this behaviour or is it a bug?