Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g (10.1.3.5.0)

Part Number E13981-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

Which Type of Enterprise Bean Should You Use?

This section describes the following:

Which Type of Session Bean Should You Use?

Stateless session beans are useful mainly in middle-tier application servers that provide a pool of beans to process frequent and brief requests.

When do you use Bean-Managed Versus Container-Managed Persistence?

In practical terms, Table 1-20 provides a definition for both BMP and CMP, and a summary of the programmatic and declarative differences between them.

Table 1-20 Comparison of Bean-Managed and Container-Managed Persistence

Management Issues Bean-Managed Persistence Container-Managed Persistence

Persistence management

You are required to implement the persistence management within the ejbStore, ejbLoad, ejbCreate, and ejbRemove EntityBean methods. These methods must contain logic for saving and restoring the persistent data.

For example, the ejbStore method must have logic in it to store the entity bean's data to the appropriate database. If it does not, the data can be lost.

The management of the persistent data is done for you. That is, the container invokes a persistence manager on behalf of your bean.

You use ejbStore and ejbLoad for preparing the data before the commit or for manipulating the data after it is refreshed from the database. The container always invokes the ejbStore method right before the commit. In addition, it always invokes the ejbLoad method right after reinstating CMP data from the database.

Finder methods allowed

The findByPrimaryKey method and other finder methods are allowed.

The findByPrimaryKey method and other finder methods clause are allowed.

Defining container-managed persistent fields

N/A

Required within the EJB deployment descriptor. The primary key must also be declared as a container-managed persistent field.

Mapping container-managed persistent fields to resource destination

N/A

Required. Dependent on persistence manager.

Definition of persistence manager

N/A

Required within the Oracle-specific deployment descriptor. By default,OC4J uses the TopLink persistence manager.


With CMP, you can build components to the EJB 2.0 specification that can save the state of your EJB to any Java EE supporting application server and database without having to create your own low-level JDBC-based persistence system.

With BMP, you can tailor the persistence layer of your application at the expense of additional coding and support effort.

For more information, see the following: