Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

CMP :: ejbCreate :: why return null ?  RSS feed

 
Poornachandran R
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In CMP,
Why do we have to return null ?
I am aware that it is container's responsibility to create the primary key and return it. Anyhow it is possible for the container to ignore what is returned from ejbCreate and it can return the primary key by itself.
Why is it specifically told to return null ?
Poorna
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the EJB 2.0 specification (14.1.2: ejbCreate, ejbPostCreate):

The ejbCreate(...) methods must be defined to return the primary key class type. The implementation of the ejbCreate(...) methods should be coded to return a null. The returned value is ignored by the Container.
Note: The above requirement is to allow the creation of an entity bean with bean-managed persistence by subclassing an EJB 1.1 entity bean with container-managed persistence. The Java language rules for overriding methods in subclasses requires the signatures of the ejbCreate(...) methods in the subclass and the superclass to be the same.

The above extract explains the reason to be support for subclassing.
[ July 21, 2003: Message edited by: Lasse Koskela ]
 
stara szkapa
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because if it is neither null nor key then whoever called the function might get confused. Imagine you purchase ticket to Florida and the agent instead of telling you there are no available sits gets you ticket to Texas.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!