Hi,
I've come out with a table as follows.
Please feel free to give your comment and correct any mistake I've made or anything you think it is useful to add.
I know cross posting is not allow, so, hopefully the guys visiting
EJB forum can pop in to have a look too.
Cheers.
Han Ming
<table border="1" width="100%">
<tr>
<td width="25%">Methods</td>
<td width="25%">Entity Bean (CMP)</td>
<td width="25%">Entity Bean (BMP)</td>
<td width="25%">Stateless Session Bean</td>
<td width="25%">Stateful Session Bean</td>
</tr>
<tr>
<td width="25%">Initial state </td>
<td width="25%">create by AppServer and put into pool</td>
<td width="25%">create by AppServer and put into pool</td>
<td width="25%">create by AppServer and put into pool</td>
<td width="25%">create by AppServer and put into pool</td>
</tr>
<tr>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">create</td>
<td width="25%">call ejbCreate in Bean class</td>
<td width="25%">call ejbCreate in Bean class</td>
<td width="25%">Does not call ejbCreate in Bean class
<p>only create an EJBObject for the client</p>
</td>
<td width="25%">call ejbCreate in Bean class</td>
</tr>
<tr>
<td width="25%">ejbCreate</td>
<td width="25%">before insertion</td>
<td width="25%">on insertion</td>
<td width="25%">creation of each bean
<p>called only once when create by EJB Container</p>
</td>
<td width="25%">creation of each bean</td>
</tr>
<tr>
<td width="25%">ejbPostCreate</td>
<td width="25%">after insertion</td>
<td width="25%">after insertion</td>
<td width="25%">NA</td>
<td width="25%">NA</td>
</tr>
<tr>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">remove</td>
<td width="25%">call ejbRemove</td>
<td width="25%">call ejbRemvoe</td>
<td width="25%">bean instance is put back to pool</td>
<td width="25%">call ejbRemove</td>
</tr>
<tr>
<td width="25%">ejbRemove</td>
<td width="25%">before deletion of record</td>
<td width="25%">on deletion of record</td>
<td width="25%">before bean is remove from memory</td>
<td width="25%">before bean is remove from memory</td>
</tr>
<tr>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">ejbActivate</td>
<td width="25%">after the Bean is activated</td>
<td width="25%">on Bean is activated</td>
<td width="25%">never called</td>
<td width="25%">after Bean is activated</td>
</tr>
<tr>
<td width="25%">ejbPassivate</td>
<td width="25%">before Bean is passivated and instance put back to pool</td>
<td width="25%">on Bean is passivated and instance put back to pool</td>
<td width="25%">never called</td>
<td width="25%">before Bean is passivated and instance destroyed after
passivation</td>
</tr>
<tr>
<td width="25%">passivation</td>
<td width="25%">only null,
java primitive, serializable, EJBHome,
EJBObject, EJBLocalHome, EJBLocalObject, UserTransaction, JNDI ENC,
SessionContext, resource factories will be preserved in conversational
state.<br>
But primitive will be restore to default values.</td>
<td width="25%">as Entity CMP</td>
<td width="25%">As they are never passivate, resource connection e.g.JDBC,
socket can remain open throughout their life</td>
<td width="25%">as Entity CMP</td>
</tr>
<tr>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">ejbLoad</td>
<td width="25%">after bean is loaded</td>
<td width="25%">on bean is being loaded</td>
<td width="25%">NA</td>
<td width="25%">NA</td>
</tr>
<tr>
<td width="25%">ejbStore</td>
<td width="25%">before bean is stored</td>
<td width="25%">on bean is being stored</td>
<td width="25%">NA</td>
<td width="25%">NA</td>
</tr>
<tr>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">setEntityContext</td>
<td width="25%">when bean is created in pooled by EJB Container</td>
<td width="25%">when bean is created in pooled by EJB Container</td>
<td width="25%">NA</td>
<td width="25%">NA</td>
</tr>
<tr>
<td width="25%">unsetEntityContext</td>
<td width="25%">before bean is remove from memory</td>
<td width="25%">before bean is remove from memory</td>
<td width="25%">NA</td>
<td width="25%">NA</td>
</tr>
<tr>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">setSessionContext</td>
<td width="25%">when created by EJB Container</td>
<td width="25%">when created by EJB Container</td>
<td width="25%">called once when created by EJB Container</td>
<td width="25%">when create is called by client</td>
</tr>
</table>