Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

ejbActivate in cmp entity bean

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I will suppress my every urge. But not this shameless plug:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic