• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

HFEJB p.560 A session bean calls getPrimaryKey() on its context

 
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In HFEJB p.560, a scenario is that A session bean calls getPrimaryKey() on its context and the bean gets an IllegalStateException.
The context version of getPrimaryKey() is exposed only to entity beans but not to session beans. If you put sessionContext.getPrimaryKey() in source code, it will get compilor error.
So how could we get IllegalStateException???
Please let me know if I am wrong.
Thanks.
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've just checked the EJB API... I don't see any getPrimaryKey() in SessionContext interface... SO you cannot get IllegalStateException by using SessionContext...
In addition, there are only two methods in javax.ejb.SessionContext; getEJBLocalObject() and getEJBObject(), while in javax.ejb.EntityContext; one more method(getPrimaryKey()) is added to obtain the primary key of the EJB object that is currently associated with this instance...
Hope it helps...
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no getPrimaryKey() method in the SessionContext interface. However, there is a getEJBObject() and getEJBLocalObject() on which you can then invoke getPrimaryKey(). If a session bean does so, there won't be any compiler error since the compiler does not interpret the code, but the container will throw a RemoteException, respectively a EJBException at runtime.
 
Steve Taiwan
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much.
I will correct my HFEJB.
I hope Kathy and Bert should see this and correct this in the latest version of HFEJB.
reply
    Bookmark Topic Watch Topic
  • New Topic