Entity bean question - HFEJB pag 364, exe: 10!

A - its ejbLoad() can be direclty called after ejbStore() B - its ejbStore can be called directly after a business method. C - One of its business methods can be called directly after ejbStore.

The asnwer is : A, B, C

Note from HFEJB: "The point is..:load , store and business methods can be called by the container in any order.."

My question is...: what about these sentences below:

- "ejbLoad() will be always called AFTER ejbActivate()" - "ejbStore() will be always called BEFORE ejbPassivate()"

- Doesn't it have to do with? - Is it just because the bean is the READY-STATE?

Please advise!!!

Tks so much!!

SCJP | SCWCD | SCBCD | SCWSD 5 | SCEA (I) 1.4 | SCEA 5 | IBM SOA 669

Amol Nayak

Ranch Hand

Posts: 218

posted 9 years ago

ejbLoad and ejbStore are called to synchronize the bean's state with the db,

So they can be called any time and not necessarily after ejbActivate and before ejbPassivate respectively.

The spec says

When an entity bean instance is in the ready state, the instance is associated with a specific entity object identity. While the instance is in the ready state, the container can synchronize the state of the instance with the state of the entity in the underlying data source whenever it determines the need to, in the process invoking the ejbLoad and ejbStore methods zero or more times. A business method can be invoked on the instance zero or more times. The ejb- Timeout method can be invoked on the instance zero or more times. Invocations of the ejb- Load and ejbStore methods can be arbitrarily mixed with invocations of business methods and ejbTimeout method invocations. An ejbSelect<METHOD> method can be called by a business method (or ejbLoad or ejbStore method or ejbTimeout method ) while the instance is in the ready state.