问题
is there any difference between:
- add "@Transactional" annotation to whole class
- add for every single method "@Transactional" annotation ?
Using spring and Hibernate ?
回答1:
Basically, if you annotate the class with @Transactional all methods will be transactional.
If you don't, you can annnotate as @Transactional only those methods you want to. Additionally, you can specify different attributes for each method, like isolation
, propagation
, timeout
, ...
Also, take a look at this question, this is a possible duplicate of it: Hibernate transaction annotations in source — difference between class and method level use?
来源:https://stackoverflow.com/questions/7482069/transactional-annotation