Entity Bean Internal Functionality is important to understand for an EJBNAuthor its life cycle is a bit complicated.
Initially the container invokes new Instance() callback method , then sends an EntityContext to the bean using the setEntityContext() method. At this particular time, the bean instance is moved into bean pool. While in the pool, an instance may be used to execute the bean’s finder methods, or ejbHome methods. The instance does not move to the Ready state on finder method execution for ejbHome methods, the bean is returned to the pool after method execution.
An entity instance moves to the Ready state either when the ejbCreate() and ejbPostCreate() method pair is called, or when the ejbActivate() method is called. While in the Ready state, an instance has a specific object identity.
ejbLoad() and ejbStore() may be called by j2ee container at any time and in any order to read from and write to the persistent datastore.
The container may also call ejbPassivate () at any time to move the instance back into the pool. Generally, the ejbStore() method will be invoked just prior to this call. As with any passivation method, resources should be released and reacquired upon activation.
An instance will be moved back to the pool if a transaction rollback occurs during ejbCreate() or ejbPostCreate() operations. ejbRemove() invocations will result in transition to the pool as well.
An instance is removed from the pool and goes to the Does Not Exist state immediately after the container calls unsetEntityContext(), so this is the time to perform any final cleanup operations.