I don't konw, Why ejb server must call ejbStore() method
after call a finder method?
The server can call ejbStore() "when needed", and the calling sequence is not specified.
(I have seen very strange calling sequences to ejb methods in some application servers.)
What the spec. is doing is to define _what_ the ejb methods should do when they are called. Not _when_ the methods should be called.
You can read more about ejbLoad() and ejbStore() in section 10.5.2 in the EJB 2.0 specification! It is not more than 23 lines of text!!
Finder methods should return accurate results even in the middle of a transaction. Generally, changes made to some entity bean within a transaction might change the results of a finder method (for instance, it may now match a certain query which it didn't match before).
Finder methods usually issue an SQL statement, and for this SQL statement to see the updated versions of the entities, they must be stored in the database. This is why the container must store entity instances prior to executing a finder method.
You can see the normative reference for this rule in section 126.96.36.199 of the EJB2.0 spec (a similar rule is found in section 10.5.3 for CMP beans):
"Before invoking the ejbFind<METHOD>(...) method, the container must first synchronize the state of any entity bean instances that are participating in the same transaction context as is used to execute the ejbFind<METHOD>(...) by invoking the ejbStore() method on those entity bean instances."
This rule is a container responsibility, which is why you won't find it in section 10.5.2 that Tomas mentioned, which is the bean provider's responsibility section. This is important to remember if you're going to be using the EJB spec: all the rules are categorized based on whose responsibility they are: container, bean provider, application assembler, etc. If you're not sure how a certain rule you're looking for will be categorized, check all the categories.
I hope this clear up the question.
I'm having a problem with the expected behaviour you descibe not occurring.
Using Weblogic 6.1 sp3, ejbStore() does not appear to be called for instances of our bean that have been updated when we are calling a finder method (resulting in updated beans not being returned by the finder method when they should be).
We do have the weblogic property <delay-updates-until-end-of-tx> set to True, but had expected that this would not effect ejbStore() being called by the container to syncronise the state of the entity bean instances in the same transaction context used to execute the ejbFind method (since the spec seems to dictate that this should always happen).
Any pearls of wisdom greatly appreciated - I'll be posting to the bea newsgroups in search of an answer as well, but it seemed a reasonable question to post in the context of this discussion.
thanks in advance