Day 11. Developing Container-Managed Persistence Entity Beans

Today you'll learn how to develop portable applications that are database independent and free of database access code. You'll work on a complete example of developing a container-managed persistence (CMP) entity bean.

In our sample University Registration System, a student selects items from the course catalog, places them in an enrollment cart, and, when ready, places an order for the cart contents. The order must live even when the student's session with the application is over. Therefore, in the sample application, the Order component is modeled as an entity bean. The Order component provides data-related logic, such as inserting, updating, and removing an order record in the database.

Today, we'll write the Order component as a container-managed persistence entity bean. Tomorrow, on Day 12, “Developing Container-Managed Relationship Entity Beans,” we'll integrate the Order component with other entity beans.

The EJB container is responsible for the persistence of a container-managed persistence bean. We'll examine how the container achieves this goal by looking under the hood of a CMP bean. Just like BMP, a CMP bean consists of a home interface, a component interface, and a bean class. We'll write these interfaces and the bean class.

The CMP deployment descriptor is the interesting part of any CMP component. The deployment descriptor has been significantly changed in EJB 2.0 to improve its portability. The bean provider designs the abstract persistence schema and specifies queries with respect to the entity bean's abstract schema. At deployment time the deployer, using container tools, maps the abstract persistent schema to a physical schema of the target database. The container tools generate the necessary additional classes that enable the container to manage the entity bean's persistence. We'll write the CMP deployment descriptor. Finally, we'll package and deploy the bean, and write a client that accesses the CMP.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.55.198