Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
R.A.Partha sarathy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is use of separate Primary Key Class in Entity Bean?
TIA
Sarathy
 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • 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.
 
Seetesh Hindlekar
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • 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
 
anjan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic