标签: java spring spring-data-jpa spring-transactions
当我使用spring服务并且我想通过spring存储库更新多个数据库表时,我是否需要添加@Transactional以确保我是事务性和回滚还是已经存在? 如果是,我是否需要将其添加到班级或方法?
答案 0 :(得分:6)
答案是肯定的,您需要单独添加。有关详细信息,请参阅:
What is the difference between defining @Transactional on class vs method
和
Spring - @Transactional - What happens in background?
https://docs.spring.io/spring/docs/4.2.x/spring-framework-reference/html/transaction.html#tx-decl-explained