当前位置: 首页 > news >正文

网站开发语言在线检测游戏网址

网站开发语言在线检测,游戏网址,团队云智能网站建设,dede减肥网站源码文章目录 前言一、同一张表1.业务代码2.测试代码3.测试结果 二、不同表1.业务代码2.测试代码3.测试结果 总结 前言 本文将介绍在springboot中使用Transactional注解来完成对数据库事务的操作#xff0c;保证数据一致性。 一、同一张表 1.业务代码 Controller Controller p… 文章目录 前言一、同一张表1.业务代码2.测试代码3.测试结果 二、不同表1.业务代码2.测试代码3.测试结果 总结 前言 本文将介绍在springboot中使用Transactional注解来完成对数据库事务的操作保证数据一致性。 一、同一张表 1.业务代码 Controller Controller public class StudentInfoController {/*** 相同表之间的事务* param s1* param s2* return*/public int transactional(StudentInfo s1,StudentInfo s2) {return studentInfoService.transactional(s1,s2);} }Service Service public class StudentInfoService {Autowiredprivate StudentInfoMapper studentInfoMapper;/*** 测试事务*/Transactionalpublic int transactional(StudentInfo s1,StudentInfo s2) {int count0;count studentInfoMapper.insertSelective(s1); // if(count1){ // throw new RuntimeException(ex); // }count studentInfoMapper.insertSelective(s2);return count;} }2.测试代码 RunWith(SpringRunner.class) SpringBootTest(classes SpringbootStart.class) public class SpringbootStartTest {Autowiredprivate StudentInfoController studentInfoController; Testpublic void test(){transactional();}public void transactional(){StudentInfo s1new StudentInfo();s1.setId(t1);s1.setName(zs);s1.setIdType(sfz);s1.setIdNumber(100);StudentInfo s2new StudentInfo();s2.setId(t2);s2.setName(ls);s2.setIdType(sfz);s2.setIdNumber(200);studentInfoController.transactional(s1,s2);System.out.println(success);} }3.测试结果 正常情况下,程序处理完成,插入了两条数据没问题 接下来,打开service中注释,主动抛出异常 二、不同表 1.业务代码 Controller Controller public class StudentInfoController extends BaseController{/*** 不同表之间的事务* param s1* param s2* return*/public int diffTransactional(StudentInfo s1, StudentCurriculum s2) {return studentInfoService.diffTransactional(s1,s2);} }Service Service public class StudentInfoService {Autowiredprivate StudentInfoMapper studentInfoMapper;Autowiredprivate StudentCurriculumMapper studentCurriculumMapper;/*** 测试事务*/Transactionalpublic int diffTransactional(StudentInfo s1, StudentCurriculum s2) {int count0;count studentInfoMapper.insertSelective(s1); // if(count1){ // throw new RuntimeException(ex); // }count studentCurriculumMapper.insertSelective(s2);return count;} }2.测试代码 RunWith(SpringRunner.class) SpringBootTest(classes SpringbootStart.class) public class SpringbootStartTest {Autowiredprivate StudentInfoController studentInfoController; Testpublic void test(){diffTransactional();}public void diffTransactional(){StudentInfo s1new StudentInfo();s1.setId(t3);s1.setName(zs);s1.setIdType(sfz);s1.setIdNumber(100);StudentCurriculum s2new StudentCurriculum();s2.setId(4);s2.setCurriculumName(1);s2.setTeacher(zjg);studentInfoController.diffTransactional(s1,s2);System.out.println(success);} }3.测试结果 正常情况下,程序处理完成,插入了两条数据没问题 接下来,打开service中注释,主动抛出异常 总结 回到顶部
http://www.zqtcl.cn/news/238689/

相关文章:

  • 新站网站如何做Seo那个网站点击率高
  • 个体做外贸的网站罗浮视窗网站建设
  • 产品企业网站上海关键词排名优化公司
  • 网站APP推广东莞人才招聘网58
  • 惠州网站建设哪家好建筑网站建设方案
  • 淄博网站制作营销wordpress 轮播图自适应
  • 响应式网站切图网站入口首页
  • 静态网站开发考虑什么网上推广引流的有用吗?
  • 网站建设包括哪些东西工业设计最好的公司
  • 网站建设方案书 模板网站地址做图标
  • 财务公司网站模板wordpress域名文件夹
  • 网站标题写什么作用是什么网络推广学校培训
  • 看室内设计效果图网站网站建设需要条件
  • html教程网站做网站用哪个服务器
  • 济南网站建设 推搜点江阴响应式网站建设
  • 网站建设在windos的设置crm平台
  • 企业如何建设网站高端商城网站建设
  • 怎么制作app网站以下什么是网页制作软件
  • 网站定制一般价格多少石家庄做网站wsjz
  • 如何建立外卖网站网站可以做的活动推广
  • 手机号注册网站cms影视源码采集
  • 网站建设网页设计培训班连云港seo优化
  • 成都网站建设公司招聘定制衣服
  • 做访问量高的网站如何建立公司网站推广
  • 做公司的网站有哪些简述企业网站建设的流程
  • 网站免费获取验证码怎么做软件开发的工作
  • 萌宝宝投票网站怎么做正规网站建设多少费用
  • 产权交易网站建设方案耐克网站建设的历程
  • 网站建设投入及费用wordpress 收录插件
  • 东莞网站制作个性化清溪网站仿做