• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

use of ejbPostCreate

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the the differernt between ejbCreate() and ejbPostCreate() .when we will use those methods.what is their purpose?
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When a create() method is invoked on the home interface of an Entity Bean, EJB container invokes the corresponding ejbCreate() method. For each ejbCreate() method, you must write an ejbPostCreate() method in the entity bean class. The EJB container invokes ejbPostCreate immediately after it calls ejbCreate().In entity beans we do not have an EJBObject during the execution of ejbCreate(). However, we do have an EJBObject by the time ejbPostCreate() is executed. The ejbPostCreate() method gives us a chance to do extra initialization after the CMP fields are initialized, but before the entity bean is used by other beans. We can't accesss getPrimaryKey() and getEJBObject() methods of EntityContext in ejbCreate(), we can do it in ejbPostCreate(). In entity bean, ejbCreate() method only creates a new record in underlying database, but primary key is not associated with that object, ejbPostCreate() method allows the ejbObject to associate it with Primary Key generated.

Hope this help!!


Thanks,
Mahesh

-----------
SCJP 1.4 | SCWCD 1.4 | SCBCD 1.3 | SCEA Part I - In Progress
 
rajareddy annavaarm
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for giving me reply.

i heard we can use ejbPostCreate() method for CMR.is it right?if so how?
 
Mahesh Desai
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To set up the CMR fields during the creation of a bean, sometimes we might need primary key and we can not get it in ejbCreate method. And also we can not invoke methods like getEJBObject(), getEJBLocalObject(), or getPrimaryKey() in ejbCreate. So we use ejbPostCreate method to set the values of cmr-fields to complete the initialization of the entity bean instance.


Thanks,
Mahesh

-----------
SCJP 1.4 | SCWCD 1.4 | SCBCD 1.3 | SCEA Part I - In Progress
reply
    Bookmark Topic Watch Topic
  • New Topic