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

ejbCreate()

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why ejbCreate()(CMP) returns null when it is supposed to return the Primary key?
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dhan,

This question (and in retrospect, your other one) belong and will be better answered in the EJB forum.

I'm going to move them both there.
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For CMP beans the EJB Container is actually responsible for implementing the persistance logic. Therefore, it is the Containers responsibility to create and return an instance of the Primary Key class for your bean. The developer merely returns null because the Container is going to ignore it anyways.
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another point is that the client code calling the EJB does not directly call the bean code that you develop. It actually calls, from the create() method, a class that the EJB container implements, subclassed from the your EJB. In this class the ejbCreate really does return a primary key. So you return null from ejbCreate because you don't need to worry about what kind of primary key gets returned.
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When using CMP you always return Null, and when using BMP you return the Primary Key.
reply
    Bookmark Topic Watch Topic
  • New Topic