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
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 ]
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.