• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Differences between ejbCreate() in CMP and BMP?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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()
 
reply
    Bookmark Topic Watch Topic
  • New Topic