File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
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....
 
 
subject: What is use of separate Primary Key Class in Entity Bean?
 
Similar Threads
what happen when a table haven't Primary Key?
primary key class of entity beans?
entity bean for a table with No Primary key : Please Help,,,, URGENT
primay key ???
set accessor method for PK