Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejbCreate()

 
dhan hazarika
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why ejbCreate()(CMP) returns null when it is supposed to return the Primary key?
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • 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.
 
Dave Cronin
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • 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.
 
Sergiu Truta
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When using CMP you always return Null, and when using BMP you return the Primary Key.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic