Primary keys

A primary key is a unique key that is part of the definition of a table. It can be used to distinguish one record from others. All records must have a primary key. When you create a new record in a table, you may need to generate a unique primary key for the record.

In the WebSphere Commerce programming model, the persistence layer includes entity beans that interact with the database. As such, database records may be created when an entity bean is instantiated. Therefore, the ejbCreate method for the instantiation of an entity bean may need to include logic to generate a primary key for new records.

When an application requires information from the database, it indirectly uses the entity beans by instantiating the bean's corresponding access bean and then getting or setting various fields. An access bean is instantiated for a particular record in a database (for example, for a particular user profile) and it uses the primary key to select the correct information from the database.