This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
1. ejbLoad/ejbStore called by container before and after executing buisness methods or you can say, before and after bean data gets updated.
2. ejbCreate will be called by container on calling create(..) in home interface. And calling ejbLoad() doesn't make sense in this case, because there is no data yet to refresh bean state. Also calling ejbStore(0 is not required because, client calls create(..) method in home to create a new record and not for updating the existing record.
After ejbCreate() method completes, container call ejbPostCreate() to finish your intialize process like, updating dependent beans.
1) ejbLoad/ejbStore is called by container only when the client calls component business methods.
This is one scenario when ejbLoad/ejb?Store is called by container.The container may call these methods n number of times as and when it wants to synchronize the bean data with the data of the entity. So this is not the onlytime they are called [ November 18, 2006: Message edited by: Rajan Murugan ]
The container will call ejbStore before calling ejbPassivate, and on a server that does active passivation, ejbPassivate is called immediately after ejbPostCreate.
I put together a neat multimedia tutorial the creates a BMP, and just codes a System.out.println("Im in ejbXYZ method"); for each of the methods of the BMP. I then load the BMP on the server, and do thing like create it and call business methods. As this happens, you see exactly what methods are called when.
If you have any doubts about when a certain ejb method is called, you should check it out. People are always blown away when the EJB invokes an ejbLoad and an ejbStore for a simple getter method.