[ Team LiB ] |
Chapter 5. EJB CMP
Container-managed persistence (CMP) is a persistence model in which the EJB container worries about persistence issues while you worry about business logic management. Under the CMP model, you leave most of the EJB persistence methods— ejbFindXXX( ), ejbLoad( ), ejbStore( ), and ejbRemove( )—empty. Based on a mapping you define in the application's deployment descriptor, the container implements those methods and crafts the SQL to map your beans to the database. EJB 2.0 CMP is a drastic departure from—and improvement upon—EJB 1.0 CMP. Nevertheless, the majority of systems in production these days are still in EJB 1.x environments. This chapter takes a look at both CMP models and describes how to use them in a production environment. As with any automated persistence mechanism, there is not a lot that EJB CMP requires you as the developer to do. The focus for this chapter is specifically on the aspects of the EJB 1.0 and EJB 2.0 CMP models that most impact persistence issues. Once you understand these concepts, you will find that you are left with almost no persistence coding to do under EJB CMP—all your work lies in setting up the database and writing deployment descriptors. This chapter assumes you have a basic understanding of Enterprise JavaBeans. It specifically assumes that you know the difference between entity and session beans and are familiar with home interfaces, remote interfaces, and implementation objects. If you do not have this background, you should review the Enterprise JavaBeans section of Chapter 9. I also strongly recommend the book Enterprise JavaBeans (O'Reilly) by Richard Monson-Haefel if you intend to do serious programming in an EJB environment. |
[ Team LiB ] |