tuscany-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amita Vadhavkar" <amita.vadhav...@gmail.com>
Subject Re: An update collision occurred when update the primary key property !
Date Wed, 02 Jan 2008 09:54:03 GMT
UpdateGenerator forms update statement with "where" clause like this -
iterate over all PKs and include them in "where" clause. Then iterate
over all changed fields and include them in "where" clause with values
set to old values from change summary. In case the PK itself is being
changed, this results in something like below -

update tableX set idX=? where idX=? and idX=oldValueOfidX

Later in ChangeOperation.execute(), when the changed fields in DObj are
referring to propertyNames,for idX, the new value is found and set for both
params above with "?", this is because the first "where" clause idX is not
marked as Collision param. This results in -

update tableX set idX=newValueOfIdx where idX=newValueOfIdx and

This results in 0 rows update in DB and seen by DAS as OCC Exception.

A simple fix will be - when changedFields includes a PK, avoid first
in where clause in UpdateGenerator. For other cases (i.e. changedFields do
include PK), keep the logic as is.

There can be cases where the PK needs to be modified in the tables - like
migration, system upgrades etc. So the above simple fix will be useful in
update of PK.

Old discussion ref -
Minor change on the top of the above discussion is making update efficient
avoiding duplicate inclusion of same column in "where" clause.

New test case - AliasTests.testModifyPK()

Submitting patch soon for this.


On Dec 31, 2007 8:48 AM, <LiTaojian@foresee.com.cn> wrote:

> Hi All ,
>    I  write a sample to test the DAS work with the DB , when execute a
> update operation on primary key ,
> an update collision occurred ,  how to deal with it if I need update the
> primary key value ?
> Best Regards
> Leo

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message