• 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

What is use of separate Primary Key Class in Entity Bean?

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is use of separate Primary Key Class in Entity Bean?
TIA
Sarathy
 
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is I think to separate the details of the internals of what constitutes the primary key itself.
This is according to the spec, and also gives more maintainability and implementation independance for the primary key.
Dan.
 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Defining a Primary Key class was a part of EJB 1.1 specs. As the ejb-jar.xml file had a tag prim-key-class and the bean developer had to code the name of the Primary Key class here.
<prim-key-class>ejb.cmpejb.AccountPK</prim-key-class>
whereas in EJB 2.0 and 2.1, the same can be replaced with
<prim-key-class>java.lang.String</prim-key-class>
The primary key could be a sequence generator or any other modes of creating one and the same gets reflected as a automatic-key-generation tag
<automatic-key-generation>
<generator-type>ORACLE</generator-type>
<generator-name>oracle_sequence</generator-name>
<key-cache-size>10</key-cache-size>
</automatic-key-generation>
Seetesh
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
your primary key .. may not be allways a single column in a table
if it's a composit key then u need a seperate primary class
and even some times ( but very rare ...)
if u have primary key is numerical field with decimal portion
then diffrent data bases stores it diffrently so
when u checking for equality of beans then it calls primary keys's
equal methods ... so u need to have a saperate class where u override
equals method...

Regards
anjan
 
That is a really big piece of pie for such a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic