Day 10. Developing Bean-Managed Persistence Entity Beans

Today, you'll work on a complete example of developing a bean-managed persistence (BMP) entity bean. You might question why you need to learn bean-managed persistence when container-managed persistence (CMP) is simpler to write and is the preferred approach. The answer is that you should use bean-managed persistence if you want complete control of managing persistence, if you're writing persistence logic to a very proprietary legacy database system, or when your persistent store is not a database.

The concept of the student is central to the sample university registration application. Multiple clients must share behavior, such as creating a student account, verifying an existing account, and updating account information. Updates to the state of a student object must be written to the persistent store. The student object must live even when the client's session with the server is over. Therefore, in the sample application, a student object is modeled as an entity bean. Today, we'll model a student entity bean as bean-managed persistence entity bean.

A BMP is responsible for managing its persistence. It consists of a home interface, a component interface, and a bean class. First, we'll examine the interaction between the client, EJB container and the entity bean by looking under the bean's hood. Next, we'll write each of the interfaces and implement the bean class.

Typically, a BMP contains calls to access the database. The data access calls can be embedded in the entity bean class or encapsulated in a helper object, known as a Data Access Object (DAO), that's part of the entity bean. Today, we'll learn about DAOs and use them to encapsulate data access calls.

The BMP deployment descriptor specifies the bean's name, the home and component interfaces, and the bean class. In addition, it specifies the bean's primary key. We'll write the BMP deployment descriptor. Finally, we'll package and deploy the bean and also write a client that accesses the BMP.

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

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