
You can specify the primary key for your container-managed entity bean when you create the bean, or later when you develop the bean business logic.
The bean's primary key can be a:
The following information explains how you create a simple primary key, a compound primary key, and how you specify that the EJB Container generates the primary keys.
The enterprise bean must have been created.
By default, the SAP NetWeaver Developer Studio assumes that the primary key is unknown, that is, the primary key will be generated automatically by the EJB Container.
Creating a Simple Primary Key
Creating a Compound Primary Key
The SAP NetWeaver Developer Studio will generate the primary key class.
We recommend that you specify the package of the primary key class.
Automatic Primary Key Generation
If your container-managed entity beans do not have a natural primary key, you can omit specifying the primary key class or the primary key fields and rely on the EJB Container to generate your primary keys. In this case, the system assumes that the primary key is unknown.
Follow the steps below to set the EJB Container to generate the bean's primary key automatically.
The SAP NetWeaver Developer Studio then:
The EJB Container will generate a system primary key field of type java.lang.Long.
The JDBC type of this column must be java.sql.Types.BIGINT and this column must be the only primary key column in the database table. For more information, see Object/Relational Mapping Rules.
The persistent fields that are (or are part of) your bean's primary key cannot be of type java.util.Date .
See also: