The Spring framework provides two means of programmatic transaction management:
-
Using the
TransactionTemplate. -
Using a
PlatformTransactionManagerimplementation directly.
The above is described here: http://static.springsource.org/spring/docs/2.0.8/reference/transaction.html
The Spring site hasnot mentioned JdbcTemplate here. As per my understanding JdbcTemplate also manages the transaction internally and this is all done in programme too.
So what’s the basic difference between TransactionTemplate and JdbcTemplate?
JdbcTemplateis not a transaction manager. It’s merely a helper class for native JDBC operations:TransactionTemplateby the way is also not a transaction manager, it’s aThe
PlatformTransactionManager(and other subclasses ofAbstractPlatformTransactionManager) is a transaction manager, as in itSo this class is responsible for the actual transaction handling, as opposed to the
TransactionTemplate, which is to be used if you instead of declarative transaction handling you want to implement it programmetically. (see this blog, though quite outdated, you will see the difference between declarative and manual)Quotes from Spring 3 Reference.
Note: Throughout the Spring Framework you will find other *Template classes as well: HibernateTemplate, JmsTemplate etc. They all follow the same pattern: template classes which radically reduce the amount of code you need to write, because all the so-called boilerplate code will be handled by them. Example (from here):
Without
JdbcTemplate:And with
JdbcTemplate: