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.
posted 12 years ago
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.