Trying to collect and understand the main points of @Transactional annotation and crossed one point. So, the main things that we need to keep in mind when using Transactional annotation are:
- Transactional annotation can be applied only to public methods [according to Does Spring @Transactional attribute work on a private method?
- Transactional annotation should be applied to the concrete classes instead of interfaces [according to Where should I put @Transactional annotation: at an interface definition or at an implementing class?
- Transactional annotation should be applied on the Service level [according to Spring @Transactional Annotation Best Practice
- If you want to exclude some public method from being annotated with Transactional when whole class is annotated you can use some propagation strategies [according to Transactional annotation on whole class + excluding a single method
Unfortunately I didn't find the answer to the question: Where it is better to put Transactional annotation - to the class or method? We can consider different situations, but mostly i am interested in the one when we have several methods which must have this annotation and some which don't.
Plus, maybe you would like to add some points to this list, that would be really great.