Win a copy of Rust Web Development this week in the Other Languages 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic