Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Snailclimb/JavaGuide
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: 1autodidact/JavaGuide
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Mar 10, 2022

  1. spring 事务 PROPAGATION_NESTED纠错

    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();
        }
    }
    ```
    1autodidact authored Mar 10, 2022
    Configuration menu
    Copy the full SHA
    ff6203b View commit details
    Browse the repository at this point in the history
  2. Merge pull request #1 from 1autodidact/spring-事务-PROPAGATION_NESTED纠错

    spring 事务 PROPAGATION_NESTED纠错
    1autodidact authored Mar 10, 2022
    Configuration menu
    Copy the full SHA
    4ef7033 View commit details
    Browse the repository at this point in the history
Loading