Originally posted by Maulin Vasavada:
While we are here on this, I would like to point one thing that could be worth keeping in mind.
I am using SUN ONE appserver and I realized that in my Bean Impl it doesn't matter to the code if I return null or the actual key object for the EntityBean's ejbCreate(), that just got inserted into the DB. This is because my Abstract EntityBean class gets subclassed by Container specific class which takes care of returning proper object from corresponding create() method...
So to the end user writing the code sometimes it might sound confusing when the code returns correct Object even if his/her ejbCreate() returns null...
Great Maulin!
I wanted to try this out for some time. In fact, the only CMP2.0 entity bean sample in Ed Roman's book returns the primary key Object and not null!
in the ejbCreate() method. (ejb1.1/2.0/2.1 specs dictate null to be returned).
I found the foll. from EJB1.1 spec, p:131, sec 9.4.2.
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 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 be the same.
So it doesn't really matter to the Container, whether the return value is null or the primary key Object.
[ March 16, 2004: Message edited by: Vish Kumar ]