• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why does the ejbCreate() returns null

 
Rishi Singh
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kathy,
Why does the ejbCreate(0 returns null in case of EJB2.0 Entity Bean which was not the case in EJB1.1.
Rgds
Rishi
SCJP,SCWCD, IBM/OOAD
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy,
I'm pretty sure that this hasn't changed with EJB 2.0 -- the way it works is that BMP beans you MUST return the primary key, and with CMP, you return null (the Container then uses what you've specified as your primary key field (or, with a compound key, the CMP fields that together make up the primary key).
So, the return type of ejbCreate() is always *declared* as the primary key type, but with CMP you are supposed to return null (although some Containers won't complain if you return anything else, because it's ignored anyway, but we recommend that you ALWAYS follow the spec, to be safe and portable.)
cheers,
Kathy
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

So, the return type of ejbCreate() is always *declared* as the primary key type, but with CMP you are supposed to return null (although some Containers won't complain if you return anything else, because it's ignored anyway, but we recommend that you ALWAYS follow the spec, to be safe and portable.)

It's cleared in return type of ejbCreate.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess it is no longer a requirement for EJB 2.0.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic