All, The J2EE tutorial says, "If a business method is associated with a transaction, the container invokes ejbLoad before the business method executes. Immediately after the business method executes, the container calls ejbStore."
I have many entity beans in my application and they are accessed within the session bean's business method. So, the transaction starts when the session bean is created. My question is when "before the business method is executed,is mentioned" does it mean before the invokation of the business method?, so when the session bean's instance is created?? Does the container invoke the ejbLoad's of all the Entity beans in the entire application as soon an instance of the session bean is created??. Pl I need a detailed explanation so that I can understand better.
So, the transaction starts when the session bean is created.
No. The transactions usually start when business methods are invoked. Here you have to understand that entity ejbs are not allowed to start/stop transactions. The reason is exactly the one you mentioned: the container needs to call ejbLoad at the beginning of the transaction and ejbStore before committing the transaction. If entity ejbs would be allowed to start/commit transactions then they should do that inside of the ejbLoad/ejbStore methods. As you might guess the container cannot honor such a contract. Hence the transaction could be started on the server, calling methods on the session fa�ade for example, or it could be started on the client. The way the transactional context propagates from one ban to the other depends whether you�re using CMT (see transaction attributes) or BMT.
My question is when "before the business method is executed,is mentioned" does it mean before the invokation of the business method?, so when the session bean's instance is created??
Usually clients get the beans after running a finder. The container takes a bean instance from the pool in order to run the finder, gets the bean instances that satisfies the finder�s criteria, caches them and calls ejbLoad to synchronize the data with the database. Now the clients (they could be other beans as well) are free to invoke business methods on that bean.
Does the container invoke the ejbLoad's of all the Entity beans in the entire application as soon an instance of the session bean is created??.
I deliberately bolded all the references you made to the session beans creation, in the context of asking about ejbLoad/ejbStore methods of the entity beans. I want you to understand that they are not related in any way. Entity beans have nothing to do with the way session beans are created or vice versa. The only way they get related is when a session bean acts as a client calling business methods of one or more entity beans. How the transaction gets created and propagated I already provided you some hints. Regards.