• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

When are ejbLoad and ejbStore called?

 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic