Spring @Transactional Class or annotation method

Trying to collect and understand the main points of the @Transactional annotation and cross one point. So, the main things that we need to keep in mind when using the Transactional annotation are as follows:

Unfortunately, I did not find the answer to the question: where is it better to add the Transactional annotation - to the class or method? We can consider different situations, but basically I'm interested in one thing, when we have several methods that should have this annotation, and some should not.

Plus, maybe you would like to add some points to this list, it would be very cool.

+4
source share
1 answer

Here is a list of the pros and (implicitly) minuses that I can think of.

Pro:

  • . , , , .
  • . , . , .
  • . , () , ( REQUIRES_NEW ). , , - . , , , , , .

Pro:

  • . , . , DRY. , IMHO, DRY, Java private/protected/public .
+1

All Articles