Entity beans with container-managed persistence and bean-managed persistence have each of them their advantages and disadvantages. The big advantage of container-managed persistence is certainly its portability, since the important aspects of persistence are treated declaratively in a developer-independent manner. It is in this direction in particular that version 2.0 offers significant extensions of version 1.1. Additionally, persistent relationships, managed by the EJB container and a great help in the mapping of complex data structures, give container-managed persistence further advantages. Version 2.1 further enhances the standardized EJB-QL available functions. Finally, the programming effort is considerably less. Entity beans with container-managed persistence thus tend to be less subject to errors.
Bean-managed persistence offers greater flexibility. The bean developer has a free hand in data storage. He or she decides how and where data are to be stored and is not limited by the specification. With the use of bean-managed persistence, the potential for the developer in tuning database queries is a lot higher then when using container-managed persistence. That is because in the case of bean-managed persistence the bean developer writes all the data access code himself. When container-managed persistence is used, the data access code is generated by the EJB container tools and is hidden from the bean developer. Genericness has its price. If the entity bean has to deal with data types that the EJB container or persistence manager does not support or supports only minimally, then there is no avoiding bean-managed persistence.