What are some tips for using bean-managed transaction demarcation?

Session beans should use bean-managed transaction demarcation, although can use container-managed demarcation. Entity beans must use container-managed demarcation.
An enterprise bean should not invoke resource manager-specific transition demarcation API methods (like j ava.sql.Connection.commit(), java.sql.Connection.rollback(), etc.) while within a transaction.
Stateless session beans should always either commit or rollback a transaction before the business method returns. Stateful session beans do not have this requirement. Instead of calling EJBContext .getRollBackOnly(), and javax.ejb.EJBContext.setRollbackOnly() , use the corresponding JTA API calls.



Interview Questions On Java,Java EE Copyright © 2018. Reads: best tracker