It's not a secret anymore!
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
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: 17410

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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: PRIMARY KEY
It's not a secret anymore!