[Originally Posted 16-Oct-2005]

I was logged into my O’Reilly Safari Bookshelf and Reading Richard Monson-Haefel’s “Enterprise JavaBeans, 4th Edtion” when I came across this comment in chapter 16.5 Explicit Transaction Management:

Although this section covers JTA, it is strongly recommended that you do not attempt to manage transactions explicitly. Through transaction attributes, Enterprise JavaBeans provides a comprehensive and simple mechanism for delimiting transactions at the method level and propagating transactions automatically. Only developers with a thorough understanding of transactional systems should attempt to use JTA with EJB.

I have to disagree with this to a point. Sure, it’s NOT the first choice to explicitly manage transactions, I’ll admit that. I mean seriously that’s *exactly* what the JTA is there for – manage transactions so you don’t have to. However, depending on the size of demand, the system you are designing, and the level of Transaction Isolation you need it’s sometimes unavoidable. In the last 5 years where I have done large-scale, real-time, applications that used EJBs 2 out of 3 of them absolutely required explicit transactions. Interestingly enough, those projects that needed Bean-Managed Transactions were all running in WebLogic, and the others on JBoss – I don’t know if that’s saying something bad about WebLogic or good about JBoss. It could just be some bizarre coincidence, but I digress.

While the Monson-Haefel crew does go on to explain how to do explicit transactions, I think their above statement is intellectually lazy. Sure, it’s hard to manage your own transactions, but they should explain [a] the challenges and [b] perhaps provide some use-cases for when you might actually want or need to manage your own transactions.

Regardless, the book explains the approaches very well. It’s worth the read.