On page 338, it is suggested that for CMP entity beans, one cannot use EntityContext to get a reference to the EJBObject in the ejbCreate() method because it's "too early". For mock exam solution number 9 on page 369, the question is: "Which method(s) from the EntityContext interface can be invoked from within the ejbCreate method.." getEJBObject() is claimed to be a correct answer. So what's the deal? Can you call it or can't you? Or can you call it and just get no answer? Chris Arthur
As far as the exam is concerned, u cannot call the following 3 from the ejbCreate() method of an Entity Bean: 1)getPrimaryKey() 2)getEjbObject()/getEjbLocalObject() 3)getUserTransaction()(For GOD's Sake its an Entity Bean, so no BMT!!!) So if u do have a question which argues this fact....my advice would be just consider it as a MISPRINT!!!
Best Regards,<br />Rajnish Bhasin.<br />SCJP<br />SCWCD<br />SCBCD
To reiterate Rajnish's comments: You cannot call getEJBObject in the ejbCreate method since it doesn't exist yet. Not until ejbCreate returns does a row exist in the database (that is after all what entity beans ARE). No stub can exist for a bean that does not exist, so calling getEJBObject makes no sense, and an exception will be thrown. In ejbPostCreate of course, it's a whole different story. Call away!