...
- 2PC is right at the corner. In case you later on need to access two distinct databases or send/receive JMS messages atomically, you just have to add the extra logic you need without touching your transaction code as you've already taken care of it.
- Resources hog can be avoided. A timeout can be set on the transaction so that you're guaranteed your database connections can't be held more than a specified amount of time. Some transaction managers even offer a configurable default timeout value so you don't even have to change your code. BTM obviously offers that.
- Transactional safeguard. Some transaction managers can be configured so that usage of the pooled connections can only be done while a transaction is running. This allows you to guarantee that all your code is transactional. Once again, BTM implements such feature via its allowLocalTransactions datasource property.
Other references
- The Hibernate team also recommend to follow the pattern described above here: http://www.hibernate.org/42.html#A5 and there: http://docs.jboss.org/hibernate/stable/core/reference/en/html/architecture.html#architecture-current-session
