I've been struggling with this for a few hours now.
I'm trying to migrate my Spring XML configuration to a full Java based configuration.
I'm using AnnotationConfigApplicationContext
as a context implementation.
I'm having trouble finding an Java equivalent for this line, from my old XML configuration:
<tx:annotation-driven transaction-manager="transactionManager" />
As a result, Spring doesn't manage the transactions.
In my Java configuration I have initialized the relevant beans for transactions: the session factory, the transactional manager, etc, but without that line, no transaction proxy is used, so no transactions are actually in place.
So my question is how do I either translate that line to my Java context configuration or how to I go about solving the problem in another way.
Any help is appreciated. Thanks.
Transactions and Proxies. At a high level, Spring creates proxies for all the classes annotated with @Transactional, either on the class or on any of the methods. The proxy allows the framework to inject transactional logic before and after the running method, mainly for starting and committing the transaction.
One of the most essential parts of Spring MVC is the @Transactional annotation, which provides broad support for transaction management and allows developers to concentrate on business logic rather than worrying about data integrity in the event of system failures.
Transactional annotation provides the application the ability to declaratively control transaction boundaries on CDI managed beans, as well as classes defined as managed beans by the Java EE specification, at both the class and method level where method level annotations override those at the class level.
You can now use @EnableTransactionManagement.
See: http://blog.springsource.com/2011/06/10/spring-3-1-m2-configuration-enhancements/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With