• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HF EJB p338, 369 ejbCreate()

 
Christopher Arthur
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rajnish Bhasin
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!!
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Christopher Arthur
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
That does make sense. The EJBObject doesn't exist yet.
So I guess it's a misprint.
Chris
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah -- in fact, some people know they are ready to take the actual exam when their frustration with incorrect questions hits a certain level/frequency.
 
Rajnish Bhasin
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats a good one Nathan...
Well that makes Chris a ready contender for the exam.
All the Best Chris...
 
Van Nguyen
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Christopher,
I got totally pissed off too.... hahaha. Step away from HFE...
Anyways, it is a typo, as confirmed by the errata(look for 369):
http://www.oreilly.com/catalog/hfjejb/errata/hfjejb.confirmed
Hope this helps,
van
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic