• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB 1.1 Changes....?  RSS feed

 
Karan V Praba
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai All,
Any body knows whats the usage of returning null in CMP ejbCreate() .

[ February 10, 2003: Message edited by: Karan V Praba ]
 
sathish kannan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In EJB 1.0, the ejbCreate() methods in bean-managed persistence (BMP) and container-managed persistence (CMP) entities are required to have different return values. In CMP entities, the bean must return a void type, while in BMP entities, the bean must return the primary key type. The logic for this discrepancy was that CMP entities are not responsible for manufacturing their own primary key -- that's the container's job -- so the return value should reflect that aspect of the bean-container contract. BMP entities, however, are responsible for manufacturing their own primary keys (instantiating them with the right values), so they need to return the key to the container and thus must have a return value of the primary key type.
Hope this would answer your question

sathish
 
Sudd Ghosh
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is directly from EJB - O'Reilly, 3rd ed, pg 93:
The ejbCreate() always returns PK type; with CMP, it returns null. It is the container's responsibility to create the primary key. This convention makes it easier for a BMP bean to extend a CMP bean. This functionality is valuable for EJB vendors who support CMP beans by extending them with BMP bean implementations-it's a technique that is more common in EJB1.1.
Sudd
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!