Discussions

EJB programming & troubleshooting: Clarifications with EJB Specification and Mastering EJB II

  1. Hi,

     Basically, under the chapter describing CMP, the source code examples return a ProductPK from the ejbCreate (Source 7.6 Page 190) method of the bean. However, the EJB 2.0 Specification seems to state that with ejbCreate methods in CMP, they should return null so that the CMP Bean can be subclassed by a BMP Bean. I am assuming that this is not a hard and fast rule, and should only be adhered to when there might be a need for the CMP Bean to be implemented using a BMP Bean. Would like someone to verify this. Thanks.

      Secondly, if we are returning null from the ejbCreate method, and we are using a custom class as the primary key, how do we handle this ? The custom PK class does not necessarily have any get/set methods in the bean, and since we are not returning the PK we created, how would the container know what PK to use ? And how do we keep track of the PK ?

    Thanks in advance
    Jega
  2. The page from the EJB Specification that I got the info is 171
  3. The ejbCreate(0 method signature should always return a PK type, but the return statement should return null in a CMP bean.