Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Spring @Service transactional?

When I am on a spring service and I want to update several database tables through spring repositories, do I need to add @Transactional to make sure I am transactional and rollback or is it already there? If yes, do I need to add it to the class level or method?

like image 885
The Strong Programmer Avatar asked Jun 13 '18 08:06

The Strong Programmer


1 Answers

The answer is Yes, you need to add it separately. For more details, please refer:

What is the difference between defining @Transactional on class vs method

and

Spring - @Transactional - What happens in background?

and

https://docs.spring.io/spring/docs/4.2.x/spring-framework-reference/html/transaction.html#tx-decl-explained

like image 90
gargkshitiz Avatar answered Nov 11 '22 07:11

gargkshitiz