| Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g Release 3 (10.1.3) B14428-01 |
|
![]() Previous |
![]() Next |
This section describes:
Stateless session beans are useful mainly in middle-tier application servers that provide a pool of beans to process frequent and brief requests.
In practical terms, Table 1-19 provides a definition for both BMP and CMP, and a summary of the programmatic and declarative differences between them.
Table 1-19 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 For example, the |
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 |
|
Finder methods allowed |
The |
The |
|
Defining CMP fields |
N/A |
Required within the EJB deployment descriptor. The primary key must also be declared as a CMP field. |
|
Mapping CMP 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 J2EE 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 major differences between session and entity beans are that entity beans involve a framework for persistent data management, a persistent identity, and complex business logic. Table 1-20 illustrates the different interfaces for session and entity beans. Notice that the difference between the two types of EJBs exists within the bean class and the primary key. All of the persistent data management is done within the bean class methods.
Table 1-20 Session and Entity Bean Differences
| J2EE Subject | Entity Bean | Session Bean |
|---|---|---|
|
Local interface |
Extends |
Extends |
|
Remote interface |
Extends |
Extends |
|
Local Home interface |
Extends |
Extends |
|
Remote Home interface |
Extends |
Extends |
|
Bean class |
Extends |
Extends |
|
Primary key |
Used to identify and retrieve specific bean instances |
Not used for session beans. Stateful session beans do have an identity, but it is not externalized. |