File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Best practice using BMT and CMT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Best practice using BMT and CMT" Watch "Best practice using BMT and CMT" New topic

Best practice using BMT and CMT

Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 1118
In EJB in Action (2nd edition) p.195,

The best approach for both managing transactions and security is to use declarative transactions (CMT) and declarative security.... CMT and BMT can't be mixed in the same bean and using BMT for one bean and CMT for another bean will cause complications quickly if one bean uses the other.

For best practice, does it mean we should define all beans with either @TransactionManagement (TransactionManagementType.CONTAINER) or @TransactionManagement(TransactionManagementType.BEAN) in an .ear, and not to define some beans with TransactionManagementType.CONTAINER and some others with TransactionManagementType.BEAN ?
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper

Joined: Apr 07, 2010
Posts: 2096

The best practice is that you use Container Managed Transactions. Apart from that, if you still want to use BMT: don't mix them.
I agree. Here's the link:
subject: Best practice using BMT and CMT
It's not a secret anymore!