• Post Reply Bookmark Topic Watch Topic
  • New Topic

Entity beans BMP and CMP

 
Aamir Khan
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Can some one please explain for Entity beans where to use BMP and where to use CMP and why.I am new to EJB so will be very thankfull if some one can explain in detail.
Thanks in advance
 
Poornima Shetty
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Aamir,
Regarding your doubt about BMP and CMP I hope this helps you:
1.)Bean Managed Persistence is selected under cases where the complexity of queries with the backend is more where you would like to handle the JDBC/SQL operations on your own.
2.)Container Managed Persistence is used when we go for simple lookup operations in database.
Thus in BMP its you who will have to manage everything but in CMP its as follows:
The CMP entity beans allows the container to handle some or all of its data access logic.Rather than coding JDBC/SQL operations in your bean class ,your container implicitly performs all database operations behind the scenes.
With CMP ,you must make some of your entity bean class's fields public so that the container can set the fields when it performs database operations on behalf of your bean.
Thus CMP handles everything on your behalf(such as Transaction Management,Database connection pooling,security etc,).
Well its vast to explain this ...but hope this gives you some idea and if any more info you are always welcomed.
Rgds,
Poornima.

 
Aamir Khan
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Poornima, need a little more explanation.
With CMP ,we can only do the simple db queries like insert, delet etc or can also do something like stored procedures? How the container will know that we are using CMP or BMP? (we have to explain this in deployment descripter I think, am I right?)
Thanks again
Aamir
 
Raul Regis
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amir,
Hope, the following explanation would clarify some of your questions.
First, you are right when you said that you specify in deployment descripter whether the bean is a CMP or BMP.
Deploying, and the usasge of CMP is verymuch tied to the vendor of the Container. I am not aware of any Application servers that support Stored Procedures for CMP beans.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!