Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejbCreate() in Entity bean returns null

 
Rahul Mishra
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why does ejbCreate() return null even though the Return Type is the primary key. I remember reading in EDRoman that ejbCreate() actually returned the Primary Key..so what are the conditions under which a null will be returned
 
Balaji VR
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ejbPostCreate() is the method that initializes your bean and contructs EJBObject. Hence, it does n't matter for the ejbCreate() method to return whatever. Once ejbCreate() is done, the container calls the ejbPostCreate() that creates EJBObject having the Primary key as identifier that in turn points to the initialized bean. (i.e the ejbPostCreate() 'ed bean)

Hope I have n't confused you more!
 
Rahul Mishra
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope..although i seem to get confused easily.. but not this time..

Thanks anyway
 
MI Mohammed
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mishra,
For a bmp entity bean, the specs says

The ejbCreate<METHOD>(...)method must return the primary key for the
created entity object.

But for a cmp entity bean the specs says

The ejbCreate(...) methods must be defined to return the primary key
class type. The implementation of the ejbCreate(...) methods should be
coded to return a null. The returned value isignored by the Container.

In cmp, the container does the figuring out of the pk, using the abstract
setter pk method, but for bmp, you have to explicitly handle and return the
pk. Remember, it's the container that does the implementation, abstract while you implements a bmp entity bean.
Hope ok.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic