This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
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

ejbActivate in cmp entity bean

 
sid nagol
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is this follwoing statement correct? why?
In ejbActivate() method Bean Provider cannot use set accessor methods for abstract persistence schema to initialize the container-managed relationship or persistent fields.

what is the ejbActivate in cmp entity bean should have.
when the bean goes to method ready state throgh ejbCreate, ejbPostCreate,
i know that in ejbPostCreate we alloate the cmr fields values and in ejbCreate we set the cmpfields primary key.

so, in same way when bean goes from pooled state to method ready throgh ejbActivate, does the container load the cmp, cmr fields.
does that mean my ejbActivate will be empty.

Thank you very much for the help
 
Kay Ra
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think ejbActivate will be empty because unless the create postCreate would have been called in the begining they will set the fields, so no need to specify them again

kay
 
sid nagol
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry , my question might not be clear.
the bean can go from pooled state to method ready state in two ways.

1) ejbCreate, ejbPostCreate,
2) ejbActivate.

my question is what if it goes through ejbActivatre?
in that case, ejbCreate, ejbPostCreate will not be called.

so does ejbActivate should set the cmp, cmr fields
(the whole question is about CMP entity beans only)

thanks
sid
 
Thomas Vezhambacheril
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in ejbActivate and ejbPassivate there is no transaction contect,secury context. But it will be able to access the primary key,getEJBLocalObject() and getEJBObject().As it is not having the transaction context and security context it will not be able to acess other beans or resource managers.So i think acessing relational filds will be a problem

Best Regards
Thomas
 
Ed Marte
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, ejbActivate and ejbPassivate do not run in a meaninful transactional context. Therefore you cannot access database or entity fields or relational fields.
And you don't have to worry about restoring the bean's cmp and cmr fields - container does it for you.

Ususally ejbActivate and ejbPassivate methods are empty, they are not very useful for anything (very rarely).

Hope it helps,
Ed
 
Seenu Reddy
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes,We no need to worry about restoring the database fileds when container called ejbActive(). When the ejbActivate() method calls, the ejbLoad() method calls implicitly to store the database fileds with the help of the primaryKey. The primerykey can get it from the EntityContext object. The container perform this job for us. If it is BMP, we need to write the code to restore the Database Fields.

Hope it helps.

Thanks,
Seenu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic