What is the difference between CMP and BMP

Answered by Jey on 2005-05-08 11:32:16:

CMP means Container Managed Persistence. When we write CMP bean , we dont need to write any JDBC code to connect to Database. The container will take care of connection our enitty beans fields with database. The Container manages the persistence of the bean. Absolutely no database access code is written inside the bean class.  

BMP means Bean Managed Persistence. When we write BMP bean, it is programmer responsiblity to write JDBC code to connect to Database.

Showing Answers 1 - 8 of 8 Answers

Jey

  • May 8th, 2005
 

CMP means Container Managed Persistence. When we write CMP bean , we dont need to write any JDBC code to connect to Database. The container will take care of connection our enitty beans fields with database. The Container manages the persistence of the bean. Absolutely no database access code is written inside the bean class.  
BMP means Bean Managed Persistence. When we write BMP bean, it is programmer responsiblity to write JDBC code to connect to Database.

Ritesh Patni

  • Jul 25th, 2005
 

CMP -- Container-managed persistence beans are the simplest for the bean developer to create and the most difficult for the EJB server to support. This is because all the logic for synchronizing the bean's state with the database is handled automatically by the container. This means that the bean developer doesn't need to write any data access logic, while the EJB server is supposed to take care of all the persistence needs automatically. With CMP, the container manages the persistence of the entity bean. Vendor tools are used to map the entity fields to the database and absolutely no database access code is written in the bean class 
 
BMP--bean-managed persistence (BMP) enterprise bean manages synchronizing its state with the database as directed by the container. The bean uses a database API to read and write its fields to the database, but the container tells it when to do each synchronization operation and manages the transactions for the bean automatically. Bean-managed persistence gives the bean developer the flexibility to perform persistence operations that are too complicated for the container or to use a data source that is not supported by the container.

suman medisetti

  • Oct 4th, 2005
 

The differences between CMP and BMP are

In CMP :no findByPrimaryKey() method,ejbCreate method returns null in bean implimentation,Container responsible for database connections and transactions,Container takes care of implimenting ejbStore and ejbLoad method.No complex queries like joins are handled by container,3 deployment descriptors files are needed.

In BMP :findByPrimaryKey method is implimented,ejbCreate method returns primarykey class type,developer responsible for database connections,Developer should take care of implimenting ejbStore and ejbLoad methods,2 deployment descriptors files are needed.

  Was this answer useful?  Yes

Anitha

  • Nov 1st, 2005
 

CMP : When a bean instance is created, the container retrieves the data from the db or persistant storage and assigns it to the object vars of the bean for the user to manipulate or use them. For this, we need to map the fields of the database to the fields in the deployment descriptor.BMP : Whenever the bean instance is created, it is the responsibility of the developer to make the connection to the database, retrieve the values, assaign it to the object variables in ejbload() method of the bean instance. similarly ejbstore() method is used to save the values from the bean to the database.The advantage of using the entity beans (EJB) is the activities such as management of database transactions, connection pooling,etc are taken care by the ejb container.

  Was this answer useful?  Yes

Debabrata Sau

  • Feb 7th, 2006
 

CMP means Container Managed Persistence. In case of CMP bean , developers dont need to write any JDBC code to connect to Database. The container will take care of connection our enitty beans fields with database. The Container manages the persistence of the bean. Absolutely no database access code is written inside the bean class.  

BMP means Bean Managed Persistence. In case of BMP bean, it is programmer responsiblity to write JDBC code to connect to Database.

For CMP beans you can map only one table at a time. But for BMP u can map more that one table at a time.

CMP bean is easy for developers but dificult tounderstand to container. So u cant execute complex query in CMP bean.

  Was this answer useful?  Yes

Kapil

  • Aug 5th, 2011
 

Only Difference that in CMP no need to Write Database Connectivity Code And In BMP no need to Write the Code

  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