posted 17 years ago
We are using websphere 5.1 and I am using CMP 2.0
I have a follwing requirement
I have unique key constraint on the table say 'table1' like following
column1 + column2 +column3 -- unique constraint say UK_X
I mapped a CMP bean for the table1 say it is called 'Table1Bean'
I have few rows in the 'table' and trying to update one row from the
screen
I am trying to update column4 of the table (not part of the unique key) and keeping the same value of the unique key column then I am getting the DuplicateKeyException caused by 'Unique Key constraint failed' exception
consider the following code on table1bean.update
update(){
setColumn1('c1');
setcolumn2('c2');
setcolumn3('c3);
setColumn4('c4_changed');
}
values for column1 and column2 and column3 is exactly same as previous values (which are part of unique key) only change is column4
When i try to run this method container throwing DuplicateKey Exception.
Note: i am calling the update() in a Stateless Session Bean
doUpdate(){
doBeanUpdate();
}
doBeanUpdate(){
// find the bean using primary key
bean.update();
}
dopdate() method has requires Transaction
and doBeanUpdate() has 'requiresNew' Transaction
Hope I explained the question correctly
I appreciate if anybody solves this problem and eagerly waiting for the answers