在Dubbo的@Service注解类中,要想实现事务管理,必须在@Service后面加上(interfaceClass = “实现的接口.class”)
例:
@Service(interfaceClass = ParaService.class)
public class ParaServiceImpl implements ParaService {
@Autowired
private ParaMapper paraMapper;
@Autowired
private TemplateMapper templateMapper;
@Transactional
public void add(Para para) {
//将模版的参数数量加一
Template template = templateMapper.selectByPrimaryKey(para.getTemplateId());
template.setParaNum(template.getParaNum() + 1);
templateMapper.updateByPrimaryKey(template);
paraMapper.insert(para);
}
}
最后
以上就是幸福水壶最近收集整理的关于Dubbo @Service注解事务管理@Transactional注意事项的全部内容,更多相关Dubbo内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复