Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Updating a Composite Primary Key in a CMP Entity Bean

 
pradeeppk
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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,
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic