1. when the caller method is calling the @Transaction annotated method from the same class
2. When the Annotated method is not public
@Transnational by default don't rollback for Checked Exceptions
class A{
void caller(){
doInTransactionMethod(); // @Transnational is ignored
}
@Transnational // by default rollback for RuntimeExceptions
public <return type> doInTransactionMethod(<params>){ // should be public as well
}
}
The problem is, I keep forgetting about the above 3 simple rules, So I tried to writing down here to try not to forget about it
Also, here is a tweet that talks about public default limitation: https://twitter.com/mohewedy/status/1099781513888100352
"By default, only public methods can be made transactional." #springframework #AnnotationTransactionAttributeSource #EanableTransactionManagement #BeanFactoryTransactionAttributeSourceAdvisor— Muhammad Hewedy (@mohewedy) February 24, 2019
I hope I never forgot about you again and again and again 😅😅😅
No comments:
Post a Comment