What is an EJB primary key? How is it implemented when the database doesn't have a primary key?

Sameer Tyagi

A primary key is an object that uniquely identifies the entity bean. According to the specification, the primary key must be unique for each entity bean within a container. Hence the bean's primary key usually maps to the PK in the database (provided its persisted to a database).

You may need to create a primary key in the database for the sake of referential integrity. This does not, however, mean you NEED a primary key in the database. As long as the bean's primary key (which maps to a column or set of columns) can uniquely identify the bean it should work.

[with minor correction from Amit Chawla.]

See also:
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact