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 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.
The primary disadvantage of
BMP is obvious: more work is required to
define the bean. You have to understand the structure of the database
or resource and the APIs that access them, and you must develop the
logic to create, update, and remove data associated with entities.
This requires diligence in using the EJB callback methods (e.g.,
appropriately. In addition, you must explicitly develop the find
methods defined in the bean’s home interfaces.
The select methods ...