posted 20 years ago
This is one of the "nasty" ones!
Entity Beans - The return value of the ejbCreate method for a CMP bean should be the PK (Class) as in:
PK ejbCreate(...) {
.
.
return null;
}
See the return null statement above? That means for the Container Managed Persistent, the container will "make" the primary-key for you, you don't have to explicitly return it. However, the method signature, i.e., PK ejbCreate(...), must have its return type as PK. In the Bean Managed Persistence, you will explicitly return the primary key value instead of returning null.
Dennis, the example that you have from Mastering Enterprise JavaBeans which says:
pk ejbCreate() for SFSB is plain wrong. Stateful session beans do not return pk, they do not have primary key, they return "void" in the ejbCreate method.
Hope this helps.
Regards.
Bharat
p.s. If you are a bit unsure of yourself in the EJB area, consider SCBCD. I was more or less forced to memorize the "Bean" law like a lawyer. It is a spec full of exceptions and sometimes they don't make much sense either, but a law is a law and that is how we have to approach it.
SCJP,SCJD,SCWCD,SCBCD,SCDJWS,SCEA