• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Updating a Composite Primary Key in a CMP Entity Bean

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a situation here where in I am trying to update a field which forms the Composite Primary key through a CMP Entity bean. The problem here is that all other except for this field gets updated. It's not throwing an error either.
I tried to print the updated value in the console just after setting it in the Update() method of the Session bean which is calling the Entity Bean Remote Interface. It's showing the updated value but it's not reflecting in the Database.
Can someone suggest a solution to this problem.
Thanks in advance,
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since the Primary Key - whether simple or composite - essentially "is" the EJB, any attempt to change it is effectively deleting the old EJB and creating a new one.
I haven't checked the spec to see if it's explicitly forbidden to change the primary key fields, but from a practical point of view, it's almost certainly safer to actually remove and create. Just make sure that the operation is wrapped in a transaction (for example, done through a session EJB) in order to ensure that the operation is atomic.
 
Barry's not gonna like this. Barry's not gonna like this one bit. What is Barry's deal with tiny ads?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic