This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes What is use of separate Primary Key Class in Entity Bean? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "What is use of separate Primary Key Class in Entity Bean?" Watch "What is use of separate Primary Key Class in Entity Bean?" New topic
Author

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

R.A.Partha sarathy
Greenhorn

Joined: Sep 30, 2003
Posts: 9
What is use of separate Primary Key Class in Entity Bean?
TIA
Sarathy
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
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.


Kishore
SCJP, blog
Seetesh Hindlekar
Ranch Hand

Joined: Feb 13, 2004
Posts: 244
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

Joined: Feb 14, 2004
Posts: 5
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


It is easier to write an incorrect program than understand a correct one....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is use of separate Primary Key Class in Entity Bean?
 
Similar Threads
entity bean for a table with No Primary key : Please Help,,,, URGENT
what happen when a table haven't Primary Key?
set accessor method for PK
primay key ???
primary key class of entity beans?