• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What distinguishes a bean-managed persistent (BMP) enterprise bean from a container-m

 
ruilin yang
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What distinguishes a bean-managed persistent (BMP) enterprise bean from a container-managed persistent (CMP) enterprise bean?
A. A BMP bean must implement the ejbLoad() and ejbStore() methods
B. A BMP bean can implement persistence to custom datastores such as legacy systems
C. A BMP bean is responsible for managing its own persistence to a persistent datastore
D. All of the above
The Sun site indicates the correct answer of the quiz above is D.
This means that CMP does have to implement ejbLoad() and ejbStore ?
Sometimes CMP can implement the above two methods ? Or CMP never needs/can implement the above two methods ?
Please comment.
I confused by the above quiz.
Ruilin

[This message has been edited by ruilin yang (edited October 31, 2001).]
 
Suresh Gnanasekaran
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yang,
What distinguishes a bean-managed persistent (BMP) enterprise bean from a container-managed persistent (CMP) enterprise bean?
A. A BMP bean must implement the ejbLoad() and ejbStore() methods
B. A BMP bean can implement persistence to custom datastores such as legacy systems
C. A BMP bean is responsible for managing its own persistence to a persistent datastore
D. All of the above
Answer is D)
A) If you don't implement ejbStore() or ejbLoad() then you can't save or load records form the database.
B) If you want to access legacy database where transaction is not supported (two phase commit) or you can't map the fields from the bean to database then you have to go for BMP
c) BMP is fully responsible for transaction
Thanks
 
ruilin yang
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. My specific question are:
1) CMP does have to implement ejbLoad() and ejbStore ?
2) Sometimes CMP can implement the above two methods ? Or
3) CMP never needs/can implement the above two methods ?
Please comments,
Thanks
Ruilin
 
shai koren
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rulin
you do have to implement those methods in both CMP and BMP meaning having:
public void ejbStore()throws RemoteException
{// this is the implementation }
the difference is that in CMP you dont write any code for the udpate in the database. you might however do other things such as preparing your container managed fields to be written to the database for example compress text of a field if needed, write to log file etc. but again unlike BMP you dont need to write the actual code for the database in the method.
Did that help?
Shai
 
ruilin yang
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shai,
Thanks for the inf. Yes you are right. I read about this. Your inf enforce my memry.
I never see that the Home interface declare the remove method.
So the remove method never need the user to declare it in the home interface ?
Thanks,
Ruilin
 
shai koren
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rullin
the user dont declare the remove method in the Home interface -i think you are right about it.
that's because the ejbRemove method is inherited from the EntityBean interface and will be called by the container before it actually removes the bean.
usually you need to call the find methods from the Home which returns you the BeanObject ( Remote ) and then you call the remove on the BeanObject not the home ( that only supply you with the EJBObject after the finder method is called.
you do have a remove() method in the EJBObject but i think it's implemented by the container.
Chees
shai koren
 
ruilin yang
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shai,
Thanks for the clarification.
This means client has to call remove method of EJBObject to remove a bean ?
Thanks
Ruilin
 
ruilin yang
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shai,
Thanks for the clarification.
This means client has to call remove method of EJBObject to remove a bean ?
Thanks
Ruilin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic