aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes When are ejbLoad and ejbStore called? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "When are ejbLoad and ejbStore called?" Watch "When are ejbLoad and ejbStore called?" New topic
Author

When are ejbLoad and ejbStore called?

Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I'm using the J2EE (1.2.1) tutorial and I'm going to ask a question that has to do with the Account example. On page 48, it 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. Because the container invokes ejbLoad and ejbStore, you do not have to refresh and store the instance variables in your business methods - the container performs these functions for you.
Further, for this particular tutorial, they specify that all methods 'require' transaction.

My question is this: What if a bean's instance variables are changed by a non-transactional method, and then no other transactional methods are called before ejbPassivate is called by the container? Will the changed data be lost? Or will the container call the ejbStore? (This is BMP also)

I'm not sure how to force passivation, so I can't test this out.
[This message has been edited by Mike Curwen (edited April 17, 2001).]
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I'll answer this myself, for those interested:

Nowhere in the J2EE tutorial (1.2.1) does it mention this, but reading another book (Ed Roman's Mastering EJB), I discovered that ejbLoad is called immediately after ejbActivate when a bean is activated, and ejbStore is called immediately before ejbPassivate when a bean is to be passivated.

This is very satisfactory, and therefore does not require a transaction on every business method that could possibly change state information.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: When are ejbLoad and ejbStore called?