Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Primary Key in Entity Beans  RSS feed

 
Yogender Butola
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we have an Entity bean without a primary key?
I don't think it is possible, but a few of my friends say it is poosible. I want to be sure on this issue. Please help.
Thanks.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, every entity bean must have a primary key. It is used by the container to locate the rows to be modified/deleted and to enforce identity. Note that it is not required to have a primary key defined for the underlying table, though that seems silly.

It is quite common to use a surrogate key -- a non-data system-generated single-column (non-hyphenated ) value. It is assigned to each new entity upon creation -- either by the container or your code -- and never changed. This isolates object identity and foreign keys from data changes.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!