• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session removal via local home?

 
Roger Yates
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm currently using HFE as study-aid, and my understanding of the methods available to the local client (p154) do not include a way of removing a session bean via the local home interface.

However, running throught the EJB 2.0 spec (section 6.4, page 60), I came across the following:
The local home interface allows a local client to do the following:
- create a new session object
- remove a session object

I thought that the only remove method in the EJBLocalHome interface was remove (Object primaryKey) and only valid for Entity beans.
If this is the case, how can bullet two above from the EJB 2.0 spec be true?

I can only assume that 'allows' in this sense means that the EJBLocalHome 'allows' you to get an EJBLocalObject which, in turn, 'allows' you to remove the session. The local home interface in this manner is indirectly allowing you to remove the session object.

To my mind the EJBLocalHome interface doesn't allow you to remove the session, it's the EJBLocalObject interface that does.

Anyone agree, or am I missing something?

Roger Yates
[ August 31, 2004: Message edited by: Roger Yates ]
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB[Local]Object is an interface available both to session and entity beans. So, while for entity beans the remove(Object primaryKey) method works fine, the specs say, in the same chapter which you've highlighted, the following:


Because session objects do not have primary keys that are accessible to clients, invoking the
javax.ejb.EJBLocalHome.remove(Object primaryKey) method on a session results in
the javax.ejb.RemoveException.
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're right Roger--you cannot use the local home to remove a session bean, since there is no way to tell the home *which* session bean to remove! With the remote home interface, as you know, there are two versions of remove--one that takes a Handle and one that takes a Primary Key. But since Handles apply ONLY to remote objects, the local version of the home interface does not HAVE the overloaded remove that takes a Handle. That leaves only the remove method that takes a Primary Key, and since session beans do not have a primary key, you cannot use this version.

So, to remove a session bean when you are using a local interface, you need the EJBLocalObject and not the home.

I'm guessing this is a cut-and-paste typo in the spec perhaps... but yes, your assumption was absolutely correct

cheers,
Kathy
 
Roger Yates
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!

Nice to know I'm not going mad!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic