I have a question with regards to the usage of CMT and BMT in terms of managing transactions in the web application. I have always felt CMT is safer to use and less work so always would choose CMT in my applications.
Are there any drawbacks in using CMT? In what situations one would choose BMT over CMT?
You are correct in saying that CMTs are safer and easier to use. They are the preferred way of handling transactions. BMTs are useful for complex transactions and rollback situations. They provide a means to more carefully control the transaction boundaries, that is, when the transaction starts and ends. With CMTs the transactions are bounded by the method. BMTs allow you to specify exactly when and where it ends.
The chief drawback to CMTs in my mind is that the entire method is part of the transaction. If this method is lengthy, then you may be spending more time in the transaction than is needed. This can tie up resources needlessly. Restructuring your code can reduce the time spent in the method.
I would use BMTs where the transaction logic is not handled adequately by CMTs. This can occur when the start and stop of a transaction is not simply at the beginning and end of a method.
In that case is it possible to have a mix of CMT and BMT in an application, so that for complex, long methods to use BMT and the rest to have CMT?
That's possible. Transaction management typically is per component level. i.e. if you applications has multiple components (like EJBs) then each component (i.e. each EJB for example) can have a different transaction management characteristic. One bean can be configured for BMT and the other can use CMT.