JDBC, Transactions, Spring Data JPA
July 30, 2021
M03 13 What is @EnableTransactionManagement for?
@EnableTransactionManagement annotation is used on top of @Configuration class to enable annotation-driven transaction management by @Transactional annotation in Spring Framework.
When @EnableTransactionManagement is used, TransactionInterceptor and TransactionAspectSupport will be used to proxy each call to @Transactional class or method, which will use PlatformTransactionManager to manage transaction.
@EnableTransactionManagement allows you to specify following values:
- Mode – sets advice mode for
@Transactionalannotation, indicates how calls to methods should be intercepted,PROXYis default mode, you can switch it to more advancedASPECTJweaving advice, which supports local calls - Order – indicates order of advice execution when more then one advice applies to
@Transactionaljoin point - proxyTargetClass – indicates whether
CGLIB Proxyclasses should be created or ifJDK Proxiesshould be created (default), this field is used only whenModeis set toPROXY