Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

 
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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.
 
I once met a man from Nantucket. He had a tiny ad
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic