Why entity's bean primary key can't be primitive? Why should I wrap int into java.lang.Integer and return null in ejbCreate(...)? Isn't the container smart enough to see in DD that my primary key is simple int ? I think every one of us has been thinking over the problem - entity's home create method returns Component interface - good; but what's this mess in ejbCreate methods in the entity bean's class ? I have to see in EJB 2.1 if there is some change. Regards Toshe
javax.ejb.EJBObject and javax.ejb.EJBLocalObject both have a method 'getPrimaryKey' that returns an Object that you can cast to the type of your primary key. A primitive isn't an Object. You could also come up with a whole host of reasons why primitives would make life hell for the container vendor.
Why should I ... return null in ejbCreate(...)?
Remember that the spec has to cover both CMP (on exam) and BMP (not on exam) use of entity beans. BMP beans return the PK because the container has no other was of getting the primary key. CMP returns null because the container doesn't get the PK from the return result. The PK is constructed by the container via the attribute values you sent in ejbCreate() and reflection based on the prim-key-class and/or primkey-field content of the DD. Strictly speaking the Java code in a CMP bean may have no reason to be aware of the definition of its PK at all.