GeekInterview.com
Series: Subject: Topic:
Question: 239 of 249

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.

Asked by: Interview Candidate | Asked on: Jul 25th, 2005
Showing Answers 1 - 6 of 6 Answers
Jey

Answered On : 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.

Yes  1 User has rated as useful.
  
Login to rate this answer.
Ritesh Patni

Answered On : 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.

Yes  2 Users have rated as useful.
  
Login to rate this answer.
suman medisetti

Answered On : Oct 4th, 2005

The differences between CMP and BMP areIn 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.

  
Login to rate this answer.
Anitha

Answered On : 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.

  
Login to rate this answer.
Debabrata Sau

Answered On : 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.

  
Login to rate this answer.
Kapil

Answered On : Aug 5th, 2011

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

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.