O'Reilly logo

Enterprise JavaBeans, Fourth Edition by Richard Monson-Haefel, Bill Burke, Sacha Labourey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Bean-Managed Persistence

From the developer’s point of view, bean-managed persistence (BMP) requires more effort than container-managed persistence, because you must explicitly write the persistence logic into the bean class. In order to write the persistence-handling code into the bean class, you must know what type of database is being used and the how the bean class’s fields map to that database.

Given that container-managed persistence saves a lot of work, why would anyone bother with bean-managed persistence? The main advantage of BMP is that it gives you more flexibility in how state is managed between the bean instance and the database. Entity beans that use data from a combination of different databases or other resources such as Enterprise Resource Planning (ERP) or legacy systems can benefit from BMP. Essentially, bean-managed persistence is the alternative to container-managed persistence when the container tools are inadequate for mapping the bean instance’s state to the backend databases or resources. In most cases, you won’t need to use BMP because most projects use relational databases which are supported by CMP, but BMP remains an excellent alternative when you need to represent data as entities from unsupported resources. When you do use BMP is likely that you will create entity beans that wrapper a J2EE Connector API that is accessing an ERP (e.g., SAP, PeopleSoft, etc.), legacy system (e.g., CICS, IMS, etc.), or proprietary resource of some type. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required