Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SessionBean doesn't contain unsetEntityContext() ?  RSS feed

 
Jolly Ag
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends ,,
Will u ppl please tell me why session bean doesnt have unsetEntityContext() .
thanx
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. It is unnecessary for a Session Bean because any clean up code can be placed in the ejbRemove and ejbPassivate methods. ejbRemove is invoked before the end of a Session Bean's lifecycle.
2. A Session Bean doesn't have an EntityContext to unset... .
The reason an EntityBean needs the unsetEntityContext is that ejbRemove may or may not be called before an instance is removed, however unsetEntityContext is always called.
 
Mathews P Srampikal
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai,
I would like to why for a session been we have setSessionCintext()method but no but no unsetSessionContext() method.Please explain.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason Entity beans have an unsetEntityContext is that the actual instances may be reused. The Entity context contains the Entitity's primary key, thus you have to clear that out before the Entity instance can be returned to the pool.
There is no such primary key used in Session beans. Session Beans are not distinguishable by primary key and are thus not returned to the pool in the same way. Stateful beans aren't pooled to begin with (and so don't need it) and Stateless beans are always considered to be identical at all times, and thus don't need it either.
Kyle
[ November 26, 2002: Message edited by: Kyle Brown ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!