spring 事务 PROPAGATION_NESTED纠错#1611
Merged
Snailclimb merged 2 commits intoSnailclimb:mainfrom Mar 13, 2022
Merged
Conversation
ROPAGATION_NESTED:如果当前存在事务,就在嵌套事务内执行;如果当前没有事务,就执行与PROPAGATION_REQUIRED类似的操作,子事务回滚外部主事务也会受到影响进行回滚 ``` @service public class UserInvokeService { @Autowired private UserService userService; @resource private UserMapper userMapper; @transactional public void invokeUserService() { User user = new User(); user.setName("zxx"); user.setAge(333333); userMapper.insert(user); userService.insertData(); } } @service public class UserService { @resource private UserMapper userMapper; @transactional(propagation = Propagation.NESTED) public void insertData() { User user = new User(); user.setName("inserByNested"); user.setAge(2222); userMapper.insert(user); int a = 1 / 0; } } @SpringBootTest public class TransactionalTest { @Autowired UserService userService; @Autowired UserInvokeService userInvokeService; @test public void testTransaction() { userInvokeService.invokeUserService(); } } ```
Contributor
Author
|
第一次给那么大的项目提pr |
Contributor
Author
Owner
👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

ROPAGATION_NESTED:如果当前存在事务,就在嵌套事务内执行;如果当前没有事务,就执行与PROPAGATION_REQUIRED类似的操作,子事务回滚外部主事务也会受到影响进行回滚