Discussions

EJB programming & troubleshooting: A Question about SessionBean and EntityBean?

  1. A Question about SessionBean and EntityBean? (3 messages)

    Hi, everyone,

    Why there has a method called unsetEntityContext() in EntityBean interface but not has a corresponding method called unsetSessionContext() in SessionBean interface?
  2. ejbRemove() is called for session beans every time the container destroyes the bean. So you can use this method to do the stuff you typically would do in unsetEntityContext().
    For entity beans ejbRemove() is only called if the user explicitly deletes the bean. I think that is the reason why the engineers at SUN invented the unsetEntityContext() for this kind of bean.
  3. so if you implement a unsetSessionContext() inside the session bean it will never be called.
  4. yes, if you write unsetSessionContext() inside the session bean it will never be called because it is not a callback method for session beans.