Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PRIMARY KEY

 
Sanjay Deshpande
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic