Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Between Bean Managed and Container Managed

 
prashanth mallikarjun
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What criterias should be considered for selection between a Bean Managed or a container Managed ?
 
faisal mahmood
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CMP requires less coding, make it easier to port easity among relational databases, no need to worry about DAO (DAO is already built in). Currently bean-managed transaction is supported only for CMP's. You cannot control the CMP's.
BMP are good when you need to used other legac systems to access data and where CMP is not good. Also, with BMP's you have control on when data is flushed to the data-store. i.e. you have full control of the bean.
Faisal
 
Matjaz Juric
Author
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The general answer would be: use CMP whenever possible. Only when CMP does not support what you would like to do (for example accessing complicated ER schemas or other than relational DBs) then you should use BMP.
In practice however some developers use BMP to achieve better performance. Also in earlier EJB versions (like 1.0) CMP did not work as expected. As technology matures this has changed.
Using CMP namely reduces the amount of code we have to write, increases the portability and reuse and makes it possible to use the container provided optimizations.
Cheers,
Matjaz

------------------
Matjaz Juric
Author of Professional EJB
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic