@Transactional annotation

is there any difference between:

  • add @Transactional annotation for the whole class
  • add for each individual annotate @Transactional?

Using spring and hibernate?

+6
source share
1 answer

Basically, if you comment on a class using @Transactional , all methods will be transactional. If you do not, you can annotate @Transactional only with the methods you want. In addition, you can specify different attributes for each method, for example isolation , propagation , timeout , ...

Also, take a look at this question, this is a possible duplicate: Hibernate transaction annotations in source - difference between class and method usage level?

+6
source

Source: https://habr.com/ru/post/897662/


All Articles