So far from my reading of EJB I have gathered that we cannot use a Bean Managed Transaction (BMT) with Entity Beans & Entity Beans strictly have to be CMT
Can someone explain why it has to be that way i.e . Why cannot we have Entity beans with BMT
posted 12 years ago
From what I understand the way that Entity Beans stay in sync with underlying datastores(i.e. a database), is via couple of the Container Callbacks namely ejbLoad() and ejbStore(). One can be sure that the container always calls ejbLoad after each ejbActivate(), and ejbStore after each ejbPassivate(), based on the spec, container may call the two mentioned callbacks at any other time or in any order for that matter. Now lets say that you'd want to have an Entity Bean with BMT demarcation, You'd put your code into ejbLaod() callback method, perhaps around JDBC code. Since there is no guarantee that ejbLoad() will be called when you'd expect it to, your TX may never complete. This is why it is illegal to have bean managed transaction with Entity Beans.