what is the importance of postcreate() call back method?


General J2EE: what is the importance of postcreate() call back method?

  1. i want explanation for postcreate()
      when it is called?
         what unSetentityContext()
  2. if i can remember correctly i think it allows you to pass multiple parameters to the create method then the create method makes the data in the db with the primary key then uses the postcreate method to set the remaining methods , you would propably needs someones elses advice thou
  3. Hi,

    1. The container calls ejbPostCreate() after it has associated your bean instance with an EJB object (so after the ejbCreate()).
    in this method you can complete your initialization by doing anything you need to that requires that EJB object, such as passing your bean’s EJB object reference to other beans.
    You might also use this method to reset certain transaction-related parameters. For example, you could keep a data status flag in the bean to indicate whether a field has been changed. Because the bean instance may have been used before, these fields might have dirty data.

    2. the unsetEntityContext disassociates a bean from its environment. The container calls this right before your entity bean instance is destroyed(when it wants to reduce the pool size).

  4. Another thing about ejbPostCreate():

    In CMP, ejbPostCreate() is invoked *after* the database insert. It is useful for operations that cannot be performed until after the database record exists (like setting foreign-key references in other EJBs).

    The vast majority of the time, ejbPostCreate() does nothing.