The @EnableTransactionManagement annotation enables Spring’s annotation-driven transaction management. Database interactions then require transaction boundaries and a configured transaction manager bean. section 14.2
Use the annotation as part of a configuration strategy:
- Define the transaction manager appropriate to the persistence API, such as JpaTransactionManager for JPA or HibernateTransactionManager for Hibernate. section 14.2 section 14.4
- Use <tx:annotation-driven transaction-manager="txManager"/> when configuring the same capability with XML. section 14.4
JPA and Hibernate configuration
A Java configuration class can declare @EnableTransactionManagement alongside persistence infrastructure. The JPA variant wires an EntityManagerFactory and JPA transaction manager; the Hibernate variant replaces these with a SessionFactory and HibernateTransactionManager while retaining annotation-driven transactions.
