• 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
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

can we hv composite primary key in Entity bean ...

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i am working on insurance project , i hv a issue where i need to implement composite primary key so how do i do that,
Thanx in advance
san
 
Author
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Create a class which will act as the Primary key for the Entity bean. It should have a constructor which initializes all of the composite elements of the key. This needs to be serializable and override hashCode() and equals() appropriately so that isIdentical() will work correctly.
From there the rest is easy.
If this is CMP, then just mark the base fields as being key fields.
VisualAge for Java (and WSAD) make doing this very easy.

------------------
Gary Craig,
Author of Enterprise Java (tm) Programming with IBM Websphere
 
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The key is to implement eauals method for composite primary key class.
[This message has been edited by ruilin yang (edited September 19, 2001).]
 
The moustache of a titan! The ad of a flea:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic