I'm currently working on a project using Spring boot. I haven't used @Transactional
annotation on most of the methods. But sometimes when an error points towards having transactional annotation, then i place the annotation on it. Also i call service methods within same service class.
My Question:
Do i have to use @Transactional
annotation on every service method.
or what is the best practice to use @Transactional
annotation in service methods.
I personally use @Transactional on every service class (directly on the class, not the methods). It is incredibly useful to avoid having to manage sessions / transactions yourself and i honestly don't see a reason not to have every method use it. I have over 30 entities and associated DAO and service classes using it at the class level and everything works great.
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