• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

return value of ejbCreate() for bmp/cmp

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got confilicting information as to the above issue:
1) CMP must return null for ejbCreate()
2) CMP/BMP follows the same signature to enalbe switch or subclass
Which is correct? especially SCEA correct?
Thanks.
Denis
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CMP must return null - As of J2EE spec.
 
Denis Wang
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
which verion of ejb spec are you talking about?
I am looking at Mastering Enterprise JavaBeans. The code example uses pk ejbCreate() for SFSB.
Denis
 
Ranch Hand
Posts: 493
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is one of the "nasty" ones!
Entity Beans - The return value of the ejbCreate method for a CMP bean should be the PK (Class) as in:
PK ejbCreate(...) {
.
.
return null;
}
See the return null statement above? That means for the Container Managed Persistent, the container will "make" the primary-key for you, you don't have to explicitly return it. However, the method signature, i.e., PK ejbCreate(...), must have its return type as PK. In the Bean Managed Persistence, you will explicitly return the primary key value instead of returning null.
Dennis, the example that you have from Mastering Enterprise JavaBeans which says:
pk ejbCreate() for SFSB is plain wrong. Stateful session beans do not return pk, they do not have primary key, they return "void" in the ejbCreate method.
Hope this helps.
Regards.
Bharat
p.s. If you are a bit unsure of yourself in the EJB area, consider SCBCD. I was more or less forced to memorize the "Bean" law like a lawyer. It is a spec full of exceptions and sometimes they don't make much sense either, but a law is a law and that is how we have to approach it.
 
Denis Wang
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cool. I got a free conslutation from a certified EJB lawyer!
By the way, the example from Mastering Enterprise JavaBeans is
pk ejbCreate() { // for <<<CMP Entity Bean>>>
...
return pk;
}
<<<SFSB>>> is my own mistake.
Thanks a lot!
Denis
 
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic