aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes HFEJB - getPrimaryKey question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "HFEJB - getPrimaryKey question" Watch "HFEJB - getPrimaryKey question" New topic
Author

HFEJB - getPrimaryKey question

Simon Ingram
Ranch Hand

Joined: Nov 30, 2003
Posts: 173
Greetings fellow ranchers!

On page 560 of Kathy and Berts justly famous book, the first bean scenario informs us that we will get an IllegalStateException if a our session bean calls getPrimaryKey() on its context.

Now the SessionContext interface does not contain getPrimaryKey. It is only accessible from the EntityContext interface, so should we not be treated to a compiler error rather than an IllegalStateException?

best regards
Simon
james edwin
Ranch Hand

Joined: Nov 22, 2001
Posts: 393
As we are not implementing "Sessioncontext" or EntityContext directly in bean code.It's implemtation is upto to the container and not to bean provider.That's why we will get not compile time exception.

Regards,

James


Regards,
James
Simon Ingram
Ranch Hand

Joined: Nov 30, 2003
Posts: 173
My point is that if I call context.BigBananas() should I expect an IllegalStateException? Surely you can only call methods on a context that actually exist, like getEJBHome(). If you call getEEEHome() I would not expect the bean to compile. Can anyone confirm this?
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
What is meant by "on its context"? There are at least three explanations.

1. The term "on its context" should be replaced by "on its EJB object". In this case, any attempt by a session bean to call getPrimaryKey() on its EJB object will result in java.rmi.RemoteException being thrown.


2. The term "on its context" should be replaced by "via its context". As you can get the EJB object via the context, then getPrimaryKey() can be called. The result will be the same, java.rmi.RemoteException will be thrown.

3. The term "on its context" remains, in which case it is a compilation error.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Simon Ingram
Ranch Hand

Joined: Nov 30, 2003
Posts: 173
Thank you Roger,

you have confirmed what I thought. If a session bean calls getPrimaryKey() on its context (not on its EJBObject) there will be a compile error. So there is an error in Head First EJB on page 560. The first bean scenario, which states that the session bean will issue an IllegalStateException.

Should I put a note to this effect in the Errata?

regards
Simon
 
wood burning stoves
 
subject: HFEJB - getPrimaryKey question