• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cmp vs bmp

 
vara prasad
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sir
1)please tell me what is the
difference between cmp and bmp
clearly. i read to many books so that i m now in confused
where exatly we can differ cmp and bmp.
if you can tell me but not give me other sources t o read
if i read those things i will confused more. so please
clearly give the differenses

2)if we put jdbc code in bmp`s pasivating method what will hapen?

thank you
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34863
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vara,
CMP is container managed persistence. This means the the EJB container handles all the database stuff for you. BMP is bean managed persistence where you have to write the code yourself.

CMP is much more common than BMP. If you have to write the code yourself, you often are better off using an object/relational mapping framework or even pure JDBC.
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vara,


2)if we put jdbc code in bmp`s pasivating method what will hapen?

Right from the top you must notice that the container saves the bean�s state into the database before passivation, calling the ejbStore(). Hence there is no reason for you to provide any database code in ejbPassivate(). However by doing so, your jdbc code will execute in a very unpredictable manner, because you have no way to control the way your container passivates/activates the bean. Hence from a design standpoint you cannot implement any business logic inside of ejbPassivate(), because you�ll never know when this logic will execute, if it will execute at all (although almost certainly ejbPassivate/ejbActivate will be called at least once in a bean life cycle).
Bottom line is that if you ever considered implementing jdbc logic inside of ejbPassivate I can recommend you only one thing: please stay away.
Regards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic