This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes PRIMARY KEY Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "PRIMARY KEY" Watch "PRIMARY KEY" New topic


Sanjay Deshpande
Ranch Hand

Joined: May 22, 2001
Posts: 111
i am yet to understand the concept of Primary key in EJB.
Does that mean i gotta have a n extra field in database to have ejbPrimary key also?
Can i omit primary key?
if i have a table emo :empid, empname then should i have field for ejb primary key?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950

1. No. However, each row in the table must be uniquely identifiable
2. Not for Entity Beans
3. Deduce from 2, above!
You need not have a single column-key, but you do have to be able to construct a class comprised of columns from the database table that uniquely identify a row. For example, if I had multiple "projects" each of which had "options", but the "option" ID wasn't unique, I'd build the PK from project and option.
A primary key need have nothing to do with database keyfields, though often it maps to one for performance reasons. What is important is that the key uniquely identifies an EJB.

Customer surveys are for companies who didn't pay proper attention to begin with.
wood burning stoves
subject: PRIMARY KEY
Similar Threads
two or more primary keys
Composite primary key and auto generation
Primary Key Class in CMP & BMP
primary key class of entity beans?
Why EJB require Primary key class