• Post Reply Bookmark Topic Watch Topic
  • New Topic

Differences between ejbCreate() in CMP and BMP?  RSS feed

 
Gonna Be
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am reading some text regarding entity beans in EJB 2.0. In the section about CMP and BMP, the author said that both these kinds of beans have ejbCreate(Integer id) and in either case, this method has to return the primary key.

The author gave a demo example, in case of BMP:


However, in case of CMP


So why in case of CMP, the ejbCreate() does not return the primary key? I have tested both these examples and things worked perfectly.
 
Ram Narayan.M
Ranch Hand
Posts: 247
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Entity bean's EJBObject instance needs Primary key to point out correct record in Relational DB table and so as to load the load the data into Java Bean...

Container creates EJBObject only after ejbCreate() since the bean's value would have been readied after ejbCreate() and new entry would have been made...

In case of CMP,

container itself takes care of recognizing the Primary Key in the bean and will assign in EJBObject instance and ejbCreate does'nt need to return primary key...

In case of BMP,

Since the bean logic is handling the persistence, it has to get to know Primary Key manually... So, in BMP, EJBObject instance gets to know Primary key value returned from ejbCreate()
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!