[英]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? 当我使用spring服务时,我想通过spring存储库更新几个数据库表,我是否需要添加@Transactional以确保我具有事务性和回滚功能,或者它已经存在? If yes, do I need to add it to the class level or method? 如果是,是否需要将其添加到类级别或方法?
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 在类和方法上定义@Transactional有什么区别
and 和
Spring - @Transactional - What happens in background? 春季-@Transactional-后台会发生什么?
and 和
https://docs.spring.io/spring/docs/4.2.x/spring-framework-reference/html/transaction.html#tx-decl-explained https://docs.spring.io/spring/docs/4.2.x/spring-framework-reference/html/transaction.html#tx-decl-explained
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.