|Prev | Next||J2EETM Developer's Guide
There are two types of persistence: bean-managed and container-managed. You declare the persistence type with the Application Deployment Tool, which stores the information in the entity bean's deployment descriptor.
With bean-managed persistence, the entity bean code that you write contains the calls that access the database. The
ejbCreate method, for example, will issue the SQL
insert statement. You are responsible for coding the
insert statement and any other necessary SQL calls.
If the container manages an entity bean's persistence, it automatically generates the necessary database access calls. For example, when a client creates an entity bean, the container generates a SQL insert statement. The code that you write for the entity bean does not include any SQL calls. The container also synchronizes the entity bean's instance variables with the data in the underlying database. These instance variables are often referred to as container-mananged fields. You declare the container-managed fields with the Application Deployment Tool, which enters the list of fields in the deployment descriptor.
Container-managed persistence has two advantages over bean-managed persistence. First, entity beans with container-managed persistence require less code. Second, because the beans don't contain the database access calls, the code is independent of any particular data store, such as a relational database. However, container-managed persistence has several limitations. See the Release Notes for a complete list of limitations.
TOC | Index