ejbActivate()->ejbLoad() and then ejbRemove().
I can't understand why the container has to go thru these process for JUST deleting the entity!!!
If the client calls remove() the server acts in the same way as the client would call another method on the bean, he will call ejbActivate (to serve the client request) and then call the ejbRemove().....
Well I'm not talking about time out here. Say, the client is calling a remove() and the bean is in passivated state. What happens then ???
I can understand that we need to call ejbActivate to bring the bean out of the pool. But why this ejbLoad(), container doing all these work , JUSt to delete the entity !!!
Giju, the behavior you describe is required by the spec (see section 10.5.3):
The container synchronizes the instance�s state before it invokes the ejbRemove method. This means that the persistent state of the instance at the beginning of the ejbRemove method is the same as it would be at the beginning of a business method (i.e., if the instance is not already synchronized from the state in the database, the container must invoke ejbLoad before it invokes ejbRemove).
The ejbRemove method can only be called when the entity bean is in the READY state. If the entity bean has been passivated it first needs to be reactivated (ejbActivate) and synchronized (ejbLoad) before being removed. I think you understand that but you don't see why ejbLoad has to be called if the bean will be removed anyway... Well, you have to see ejbRemove as just another business method which requires that the entity bean fully reflect the current state of the database. The container doesn't make any difference between a call to a business method and a call to the ejbRemove method when an entity bean is pooled and has to be readied again. The bottom line is that ejbLoad is always called directly after ejbActivate has been called. I have verified this information with BEA Weblogic 7 application server implementation, but I think other servers are behaving the same way
I hope this answers your question.
Well of course you are right (I've read over the ejbLoad :roll: ) but the answer is nearly the same, the server doesn't know (care) which method is called and so calls ejbActivate and then ejbRemove (for statefull session and for entity beans).
The reply that Valentin explains makes sense -- "when the spec says that the container treats the ejbremove() method as any other business method"
But what i feel is, this is totally unnecessary - to do all these work (ejbActivate+ejbLoad()) just to delete the entity from the database.
Originally posted by Peter Wiederkehr:
@Valentin Crettaz with 6330 posts you should be able to answer my question
Working on it