Spring @Service 是事务性的吗? [英] Is Spring @Service transactional?

查看:81
本文介绍了Spring @Service 是事务性的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在使用 spring 服务并且想通过 spring 存储库更新多个数据库表时,是否需要添加 @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?

推荐答案

答案是肯定的,需要单独添加.更多详情请参考:

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

定义@有什么区别类与方法的事务性

​​Spring - @Transactional - 后台会发生什么?

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

这篇关于Spring @Service 是事务性的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆