调用createUser3方法时,会调用内部事务方法createUser4
预期:小王成功插入,小红没有插入
实际:小王和小红都没有插入
请问下:为什么小王没有插入到数据库?小红插入失败回滚会什么会导致小王也回滚了?
@Transactional(propagation = Propagation.REQUIRED)
public void createUser3() {
this.baseMapper.insert(buildUser("小王","12313131"));
// 事务生效
((UserService) AopContext.currentProxy()).createUser4();
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void createUser4() {
this.baseMapper.insert(buildUser("小红","12313131"));
throw new RuntimeException("yyyy");
}