Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Differences between ejbCreate() in CMP and BMP?

 
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.
 
Ranch Hand
Posts: 247
Eclipse IDE Chrome 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()
 
knowledge is the difference between drudgery and strategic action -- tiny ad
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic