Q. In BMP how are transactions managed if none of the EJB callback methods are implemented and no session contex is initialized. and in the deployment descriptor traction type = container : <transaction-type>Container</transaction-type>.
EJB Callback methods (ejbActivate, ejbCreate, etc) are not related to transactions. Your holding the SessionContext has no impact on container managed transactions. The container will still start/commit/rollback transactions based on your transaction-attribute setting (Required, Supports, etc.) no matter what you implement.
For this case, if I have traction type = Bean
without initializing transaction context, is the bean set to handle transactions
i.e in any BMP if the transaction context is not set how does the EJB handle transactions?
To do Bean-managed transactions (which I don't recommend unless you absolutely must), you will need to get the UserTransaction object from the SessionContext, thus
you should implement setSessionContext to keep the context. As in:
Q. For CMP there is no need to implement callback methods. but the deployment descriptor traction type must be = container : <transaction-type>Container</transaction-type>. Is this correct Correct. The container will manage the transactions for you.
Q. If session beans and data access beans ( no entity beans)are used in the application design where or how does the transaction logic works? For this, you mark the transaction attribute on the Session Bean and let the container manage it. As long as the data access is done using a TxDataSource obtained in a J2EE compliant way, then those
JDBC calls will be included in the transaction. That is, use the JDBC Connection you get from TxDataSource, and get the data source from JNDI via a res-ref setting, as in "java:comp/env/MyDataSource".
Hope it helps.
-- Dave