use of ejbPostCreate() method in Entity Beans

Discussions

EJB design: use of ejbPostCreate() method in Entity Beans

  1. Hi,
    I would like to know the usage and implementation details of the ejbPostCreate() method.

    Thanks,
    MK
  2. For each ejbCreate() method, you need to provide a ejbPostCreate() method with same signature but with void as return type. The usage is, when the ejbCreate() method is executing, the bean instance is not associated with EJBObject, i.e. the bean instance doesn't have identity. So if you want to pass your EJBObject's reference to another bean you can not do it from ejbCreate. Thats why we have ejbPostCreate().

    Hope this help,
    Senthil.
  3. The container calls the ejbPostCeate() method when it has already associated the bean instance with an EJB object. This is helpfull if we need to perform some test or throw some exceptions. Like while inserting the data in to the table we may get the exception as DuplicateKeyException.
    Since we have the EJBObject in this ejbPostCreate method we can reset some transaction related parameters.
    Regards
    Suhas
  4. thanks!![ Go to top ]

    thanks......that helps!!

    :MK