I seem to have lost my pencil sharpener . . . The first question asks what EntityBean interface container callback method best answers the following question - "the client calls this method to tell the Container that he (the client) is done using the bean's EJB object reference". the container callback choices are pretty limited, 7 in all: setEntityContext() unsetEntityContex() ejbRemove() ejbActivate() ejbLoad() ejbPassivate() ejbStore() And the only one exposed to the client in ejbRemove() (via the home and component interfaces remove()). My problem is that this method does far more than simply kill the EJB object and entity bean instance. The "there are no Dumb Questions" section on page 357 goes on about how the container garbage collects the EJBObjects and beans they represent - which seems to be the clients real goal in this question. Is the answer really ejbRemove()? Am i just having last minute exam paranoia?
Originally posted by carlos: Is the answer really ejbRemove()?
NO. ......The correct answer is no such method exists for entity bean!... This question puzzled me also. Shamefully, I checked up the answers Did you try the second question on the same page:323? Which method is called when the bean goes back to the pool after an entity is deleted from the database? Answer : ejbPassivate()? ejbPassivate() is not called for an entity bean that has just been deleted by the client.(ejbRemove() method is called before the entity is deleted and ejbPassivate() is not called after the entity is deleted!)....So the correct answer is ...no method is called when the entity bean goes back to the pool after the deletion! EJBObject garbage collection is vendor-specific. I think U are perfectly alright. Good Luck for the exam! [ April 02, 2004: Message edited by: Vish Kumar ]
Shamefully I want to know where you checked the answers ... the book doesn't give you the answers to must of the "sharpen your pencil" ...
If the answer to question 2 here is "there's no such method" it means the ejbRemove is called BEFORE the entity is removed from the database ...
I know ejbLoad happens after the db call ... I know ejbStore happens before the db call .. I am guessing ejbRemove happens before the db call ... can anyone confirm this? [ July 02, 2004: Message edited by: Lionel Orellana ]
Client calls remove() on comp interface -> Container invokes ejbRemove() on the bean -> Container deletes an entity from persistent store (eg, record from db)
That is what the spec says about ejbRemove(14.1.3)
The container invokes the ejbRemove() method on an entity bean instance with container-managed persistence in response to a client-invoked remove operation on the entity bean�s remote home or remote interface. The entity Bean Provider can use the ejbRemove method to implement any actions that must be done before the entity object�s representation is removed from the database. The container synchronizes the instance�s state before it invokes the ejbRemove method. This means that the state of the instance variables at the beginning of the ejbRemove method is the same as it would be at the beginning of a business method. After ejbRemove returns, the container removes the entity object�s representation from the database.