Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bean things for ejbActivate

 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
In the HF, it is said that ejbActivate can get access to primary key as well as EJBObject.
I have a concern here. ejbActivate will be called on a bean in pool. So no information about primary key or EJBObject will be related with that bean in the pool. Then how can we get access to primary key and EJBOject from ejbActivate.


Thanks and Regards
 
Napu Sun
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
before running ejbActivate(), the container will give the EJBObject identity to the entity context.
 
Awishek sinha
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gowda
Remember ejbActivate() is called after the container avtivates the bean instance so container has already assigned the EJBObject & primarykey to the bean instance before calling this method.
See ejb specification 2.0 page 171
--------------------------------------------------------------------------
public void ejbActivate();
The container invokes this method on the instance when the container picks the instance from
the pool and assigns it to a specific entity object identity. The ejbActivate() method gives
the entity bean instance the chance to acquire additional resources that it needs while it is in the
ready state.
This method executes with an unspecified transaction context. The entity bean must not
attempt to access its persistent state or relationships using the accessor methods during this
method.
The instance can obtain the identity of the entity object via the getPrimaryKey(), getEJBLocalObject(),
or getEJBObject() method on the entity context. The instance
can rely on the fact that the primary key and entity object identity will remain associated with
the instance until the completion of ejbPassivate() or ejbRemove().
 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks awishek,
That cleared my confusion


Thanks and Regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic