What is difference between BeanMangedPersistance and ContainerMangedPersistance?

CMP: Tx behaviour in beans are defined in transaction attributes of the methods
BMP: Programmers has to write a code that implements Tx behaviour to the bean class.
Tuned CMP entity beans offer better performance than BMP entity beans. Moving towards the CMP based approach provides database independence since it does not contain any database storage APIs within it. Since the container performs database operations on behalf of the CMP entity bean, they are harder to debug. BMP beans offers more control and flexibility that CMP beans.

Diff 1) In BMP you will take care of all the connection and you write the SQL code inside the bean whereas in CMP the container will take care of it
Diff 2) The BMP is not portable across all DB’s whereas the CMP is.

Showing Answers 1 - 3 of 3 Answers

svsathya

  • Mar 31st, 2007
 

Bean-managed persistence is more complicated 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. Bean-managed persistence gives you more flexibility in how state is managed between the bean instance and the database. Entity beans that are defined by complex joins, a combination of different databases, or other resources such as legacy systems will benefit from bean-managed persistence. Essentially, bean-managed persistence is the alternative to container-managed persistence when the deployment tools are inadequate for mapping the bean instance's state to the database. It is likely that enterprise developers will use bean-managed persistence for creating custom beans for their business system.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions