aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Updating a Composite Primary Key in a CMP Entity Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Updating a Composite Primary Key in a CMP Entity Bean" Watch "Updating a Composite Primary Key in a CMP Entity Bean" New topic
Author

Updating a Composite Primary Key in a CMP Entity Bean

pradeeppk
Greenhorn

Joined: Jan 31, 2002
Posts: 7
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,
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16065
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Updating a Composite Primary Key in a CMP Entity Bean