• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Primary Key in Entity Beans

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic