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