Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

ejbCreate() in Entity bean returns null

 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope..although i seem to get confused easily.. but not this time..

Thanks anyway
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Nothing up my sleeve ... and ... presto! A tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic