With EJB 1.1 specs, why is unsetSessionContext() not provided in Session Beans, like unsetEntityContext() in Entity Beans

This was the answer Provided by some one... According to Mohan this one is not correct. Please see Mohan's reply below and more in the comments section.

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.


Answer posted by Mohan on 2005-05-21 19:32:46:

[Quote] 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. [Quote] 
 
Who ever wrote this is wrong there is a difference between the ejbRemove and unsetEntityContext.. the difference is when ejbRemove is fired the bean is returned back to the instance pool .. at this point the bean is not associated with any client and it does not represent any data .. when the container calls the unsetEntityContext the bean is removed from the instance pool ...

Showing Answers 1 - 3 of 3 Answers

Mohan

  • May 21st, 2005
 

[Quote] 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. [Quote] 
 
Who ever wrote this is wrong there is a difference between the ejbRemove and unsetEntityContext.. the difference is when ejbRemove is fired the bean is returned back to the instance pool .. at this point the bean is not associated with any client and it does not represent any data .. when the container calls the unsetEntityContext the bean is removed from the instance pool ...

  Was this answer useful?  Yes

Mohan

  • May 21st, 2005
 

to elaborate typically ejbRemove may be called on a been n number of times during it's life time .. but unsetEntityContext will only be called once on a bean.

  Was this answer useful?  Yes

Madhavikari

  • Apr 20th, 2006
 

For session beans, there is no need to call the for removing the instace of a bean. If the session is expired automatically the ejb container will remove the instance of the bean.

But, for entity beans, those r persistente. So, container shoul call the unsetentitycontext() method. Then that time only the the instance will be removed.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions