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.
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 ]