Would roll back work if auto commit is turned on? if not then what is the implications of turning auto commit off?
@Transactional(rollbackFor = {ManagerException.class})
public myMethod()....{
System.out.printLn(my_spring_stored_procedure.getDataSource()
.getConnection().getAutoCommit()) //true
....
try {
result = this.my_spring_stored_procedure.execute(params);
}catch(DataAccessException e){
throw new ManagerException(e);
}
}
As most of you probably know, due to the very nature of the solution, Spring's @Transactional annotation does not work on private methods unless you're using the AspectJ mode (which, in my experience, most of us aren't).
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.
The @Transactional annotation is the metadata that specifies the semantics of the transactions on a method. We have two ways to rollback a transaction: declarative and programmatic. In the declarative approach, we annotate the methods with the @Transactional annotation.
So when you annotate a method with @Transactional , Spring dynamically creates a proxy that implements the same interface(s) as the class you're annotating. And when clients make calls into your object, the calls are intercepted and the behaviors injected via the proxy mechanism.
Yes. If you check the code, you will find that when the spring uses this kind of way to do the transaction. If your config is that auto commit is true, then it will change it to false and after the transaction it will change it to true.
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