Hello,
I have 2 major confusions regarding the EntityEJB lifecycle:
1)I dont understand why ejbActivate is called on an instance when ejbFind has been called on an instance and it has returned a PK to the Appserver(Home object).At this stage,the instance fields are instantiated and the bean is in a method-ready state.But it seems from the EJB lifecycle diagram, that even after ejbFind has been called, the bean is still in the pool with no state associated to it,which is incorrect.
2)In an CMP, why is ejbLoad/ejbStore called after ejbFind(findByPrimaryKey)?Since the bean has just completed loading
the values from the DB,what is the purpose of calling another ejbLoad+ejbStore on the instance.Isnt this a waste of resources?
Guys,What did i miss ??
-
Entity bean Lifecycle (3 messages)
- Posted by: Jatin Taneja
- Posted on: March 24 2004 17:41 EST
Threaded Messages (3)
- Entity bean Lifecycle by Paul Strack on March 24 2004 21:47 EST
- Entity bean Lifecycle by Jatin Taneja on March 24 2004 22:52 EST
- Entity bean Lifecycle by Gal Binyamini on March 25 2004 10:28 EST
- Entity bean Lifecycle by Jatin Taneja on March 24 2004 22:52 EST
-
Entity bean Lifecycle[ Go to top ]
- Posted by: Paul Strack
- Posted on: March 24 2004 21:47 EST
- in response to Jatin Taneja
The ejbFind method does not populate the EJB with state information. The only thing the ejbFind method does is return primary keys; nothing else.
If this confuses you, think of this: an ejbFind method can also return a collection of keys, rather than one key. Ultimately those keys will be used to populate a collection of EJB with state. There is no way this can be done in the ejbFind method of the first EJB, which is why ejbFind and ejbLoad behave the way they do.
Also note that this is only an issue for BMP. CMP Entity beans tend to be much more effecient. -
Entity bean Lifecycle[ Go to top ]
- Posted by: Jatin Taneja
- Posted on: March 24 2004 22:52 EST
- in response to Paul Strack
But then what happens in case of a BMP?...where the ejbFindByPrimaryKey method is actually used to load the fields from the DB and initialize the bean instance. After the method completes, is the bean still in the pool,even though it has a state now? -
Entity bean Lifecycle[ Go to top ]
- Posted by: Gal Binyamini
- Posted on: March 25 2004 10:28 EST
- in response to Jatin Taneja
But then what happens in case of a BMP?...where the ejbFindByPrimaryKey method is actually used to load the fields from the DB and initialize the bean instance. After the method completes, is the bean still in the pool,even though it has a state now?
No ejbFind method (including ejbFindByPrimaryKey) populates the fields of a bean. The correct way to implement ejbFind methods is to simply find and return the appropriate PK (or collection of PKs). No changes to bean state are necessary, and any changes that you make would be ignored anyway.
Gal