• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

cmp UNIQUE KEY CONSTRATINT

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic