What's the difference between using @Transactional and Spring template?

The Spring template classes are only there to provide a nicer API for doing persistence operations - they do not deal with transactions. If you want to have transactional operations, you either need to use the @Transactional annotation approach, or use TransactionTemplate.


The difference between using annotation-based transaction demarcation (@Transactional) and the TransactionTemplate is that TransactionTemplate couples you to Spring's transaction infrastructure and means that you will programmatically handle setting the transaction status if the transaction should be rolled back. You can use annotation-based transaction demarcation with the Spring transaction support or with AspectJ transactions outside of a Spring container.

See also the online documentation for transactions in Spring.