In CMP entity bean, container creates first a bean instance, calls setEntityContext, calls ejbCreate() on the bean instance and update the database, creates an EJBObject, assign the bean instance to the EJBObject, and call ejbPostCreate()
posted 17 years ago
herve Which is true, even i thought the same thing. But in the page number 213 of Richard Monson in the topic "Transitioning from the Pooled state to the Ready State via creation" it states that first EJB object must be created and then bean instance is taken from the instance pool and assigned it to EJB object. Next the ejbCreate() method is executed. Is this same thing or different for my question. Thanks herve Konda...
Hi... even I was confused about the same thing bout what Konda said but my stand on this point is that the lifecycle specified by Herve, container creates first a bean instance, calls setEntityContext, calls ejbCreate() on the bean instance...... is basically the transition from 'Does Not exist state' to 'Pooled state' and what Konda says is transition from 'Pooled state' to 'Ready state' when the bean instance is already created.... Thanx, Vidya
posted 17 years ago
An ejbCreate(), ejbPostCreate() callbacks methods are only called once in the bean's life cycle !!! my answer was referring to these point because you mentioned these callbacks methods. A EJBbean (entity and stateful session) can go back and forth between the ready state and pooled state (activation/passivation). The client is not aware about these mechanism . The container uses the ejbPassivate(), ejbActivate(),( + ejbLoad(), ejbStore() if entity bean only ) to synchronise the bean fields. The client is still referring the same EJBObject after the EJBBean has been passivated !!! it is why container, during activation, takes a EJB Bean from the pool and assigns it to the EJBObject.
According to people who took the part-1 exam, it is very important to understand EJB life cycle. The following two problems which posted by Srividya may be worth discussing again. 8.A reference to an EJB can be stored by a client for later use by: a) serializing the EJBObject to disk b) Adding the object to the server's pooled objects c) implementing a find for the bean d) storing the Handle of the EJB for the bean object 10.A developer successfully creating and tests a stateful bean following deployment, intermittent "NullpointerException" begin to occur, particularly when the server is hardly loaded. What most likely to related problem. a) setSessionContext b) ejbCreate c) ejbPassivate d) beforeCompletion e) ejbLoad
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad: