Here is the code snippet.
public class A{
public void m1(){
//Do some stuff
m2();
}
@Transactional
private m2(){
// Some DB operations
}
}
In the above code, @Transactional is not working.
Is there a way where I can create @Transactional only on private method (not on public)?
Can someone please help.
There is no purpose of keeping @Transactional on private method, because this method eventually being called within the class itself. So proxy will never apply on that method.
When using proxies, you should apply the
@Transactionalannotation only to methods with public visibility. If you do annotate protected, private or package-visible methods with the@Transactionalannotation, no error is raised, but the annotated method does not exhibit the configured transactional settings.
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