Chapter 6. Entity Beans with BMP

Topics in This Chapter

  • Introducing Entity Beans

  • Bean-Managed Persistence

  • EJB Container Responsibilities

  • DAO Pattern with Entity Beans

  • Transactions

  • Session Facade Pattern

  • Local Interfaces

Even the most patient reader is likely to wonder when we'll begin using EJB examples that show how to manipulate database records other than to simply read them. We have seen stateless session beans effectively read and cache database records. We've used stateful session beans to track where in the data list the client is currently reading, and we've used stateful session beans to hold objects in a virtual shopping cart for clients. We've even used a stateless session bean to discover the wonders of interest rates, monthly payments, and amortization tables.

The real work and power of enterprise computing, however, lies in being able to create, remove, and update database records with the confidence that the data is always consistent and synchronized with all clients, as well as with the permanent data store. To accomplish this difficult task, you use entity beans. In the J2EE architecture, you define business data with entity beans. These beans that you build work together under the management of the EJB container to provide data integrity.

Entity beans are nothing more than a reflection of data stored in a database (and they also offer helpful “finder” methods). But, by being data in memory and easily accessible, entity beans open up the database so that clients widely distributed can safely access (update, create, remove) this data. Because the entity bean is just a vessel for data, the J2EE architecture must provide the system services that allow the data transactions to occur in a thread-safe, consistent, and efficient manner.

In this chapter we explore the Bean-Managed Persistence (BMP) mechanisms of entity beans, the services provided by the bean, and the services provided by the EJB container. We also explore design techniques for using entity beans efficiently and the importance of using session beans with entity beans in an enterprise application. Best of all, we'll add persistence to our Music Collection application!

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

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