>From page 169 of Oreilly's Enterprise JavaBeans 2nd Edition:

The ejbCreate() method returns void in EJB 1.0 and a null value of type
ShipPK for the bean's primary key in EJB 1.1. The end result is the same:
in both EJB 1.0 and EJB 1.1, the return value of the ejbCreate() method for
a container-managed beain is ignored. EJB 1.1 changed its return value from
void to the primary key type to facilitate subclassing; the change was made
so that it's easier for a bean-managed bean to extend a container-managed

In short, the method signature in EJB 1.0 was void ejbCreate(), while in
EJB 1.1 it's BeanPK ejbCreate().


Ben Christensen wrote:

> When I generate a CMP bean with a Primary Key Class, it compiles and
> packages fine as far as the java side is concerned, however, when it is
> deployed, it has an issue.
> According to page 69 of the J2EE developers guide (I checked to be sure
> I wasn't just talking about anything), it says that if the bean has
> Container Managed Persistence, then the ejbCreate method should return
> null... the container handles that along with ejbFindByPrimaryKey...
> So, I have left it as null, but am using a custom Primary Key class.
> When I try to deploy it, it says:
> Error compiling ... filename ... method public void ... ejbCreate()
> throws javax.ejb.CreateException, java.rmi.RemoteException doesn't
> return a ... PrimaryKey (the path to the primary key class)
> Then the deploy fails.
> In JBoss, just to see what it had to say, it at least will deploy it but
> still gives a warning saying:
> "The return type of an ejbCreate(...) method must be the entity bean
> primary key type."
> >From what I can tell in the documentation, these errors are wrong
> On a BMP bean, then yes I should have to return the Primary Key class
> type from the ejbCreate method, this is stated in the developers guide,
> but not for a CMP bean.
> In the 1.3 preview release of the developers guide, it states the same
> thing for BMP beans, however, it doesn't say anything about CMP -- it
> says TBD ... maybe To Be Discussed... like TBA, I don't know... but
> considering we're still using 1.2.1 standards, I'd like to know if I'm
> just completely wrong, or this issue has been overlooked in the
> orionserver (and jboss to some degree) deployment.
> If it has changed since earlier versions of EJB specs and I'm just not
> seeing it, I'd appreciate someone explaining it to me.
> I've run this through VisualAge Enterprise Edition 3.5 as well... it
> works fine with ejbCreate returning null on a CMP with a primary key
> class, and if I try to tell it to return the key type, then it flags
> warnings about it.
> I can fool it into thinking everything is alright by setting the
> ejbCreate to return the primary key, but is this the correct way of
> doing this considering what the specs say?
> Thanks in advance.
> --
> Ben Christensen
> Novisum Development Inc.
> 780-909-4707

Jeff Hubbach
Internet Developer
New Media Designs, Inc.

Reply via email to