Skip Headers

Oracle® Containers for J2EE Orion CMP Developer's Guide 10g Release 3 (10.1.3) B19177-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# Configuring Callback Methods for EJB 2.0 Entity Beans With Container-Managed Persistence

In your entity bean class (see "Implementing the Entity Bean Class"), you have to provide the following configurations of the entity bean's callback methods (see "Callback Methods"):

- Provide the `ejbCreate` method with parameters matching the associated `create` method defined in the home interface (see "Implementing the Entity Bean Home Interface"). See the implementation of this method in the Example 4-3, "Implementing the Entity Bean Class".

- Set the primary key (see "Configuring Primary Key") in the `ejbCreate` method. See the implementation of this method in the Example 4-3, "Implementing the Entity Bean Class"

- Define the primary key relationships, if any, in the `ejbCreate` method. See the implementation of this method in the Example 4-3, "Implementing the Entity Bean Class".

- Define the `javax.ejb.EntityContext` for your bean in the `setEntityContext` method (see the implementation of this method in the Example 4-3, "Implementing the Entity Bean Class"). You can also allocate any other resources that will exist for the lifetime of the bean within this method.

- Unset (set to `null`) the bean's associated entity context in the `setEntityContext` method. Release other resources, if any, in the `setEntityContext` method. See the implementation of this method in the Example 4-3, "Implementing the Entity Bean Class").

The rest of the callback methods only require an empty implementation in the entity bean class–the container provides the full implementation for these methods. However, depending on the logic of your entity bean implementation, you may take actions similar to the following:

- Define the foreign key (see "Configuring Foreign Key in a Composite Primary Key") in the `ejbPostCreate` method.

- Retrieve resources in the `ejbActivate` method and release them in the `ejbPassivate` method.