GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  EJB
Go To First  |  Previous Question  |  Next Question 
 EJB  |  Question 61 of 175    Print  
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 ...




  
Total Answers and Comments: 3 Last Update: April 20, 2006   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
May 21, 2005 19:32:46   #1  
Mohan        

RE: With EJB 1.1 specs, why is unsetSessionContext() not provided in Session Beans, like unsetEntityCont...
[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 ...

 
Is this answer useful? Yes | No
May 21, 2005 19:36:49   #2  
Mohan        

RE: With EJB 1.1 specs, why is unsetSessionContext() not provided in Session Beans, like unsetEntityCont...
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.
 
Is this answer useful? Yes | No
April 20, 2006 08:05:43   #3  
Madhavikari Member Since: April 2006   Contribution: 13    

RE: With EJB 1.1 specs, why is unsetSessionContext() n...

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.


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape