我在service層調(diào)用多個dao層方法,到用mybatis代理,其中一個出現(xiàn)問題之前的不回滾@Override @Transactional(isolation=Isolation.DEFAULT, propagation=Propagation.REQUIRED, rollbackFor=UserException.class) public boolean saveUser(RegistUserDTO newUser) throws UserException{。。。。。。 UserBasePO userBasePO = new UserBasePO(); UserProfilePO userProPO = new UserProfilePO(); UserAuthenticatorPO userAuthPO = new UserAuthenticatorPO(); //將DTO轉(zhuǎn)PO傳DAO層 //先操作主表 dozerMapper.map(newUser, userBasePO); userBasePO.setNickname(newUser.getIdentity()); userBasePO.setAvtor("//"); userBasePO.setUserScore(0); userBasePO.setUserGrade(0); int saveUserBaseResult = dao.saveUserBase(userBasePO); if(1==1){ //throw new RuntimeException(); throw new UserException("存入新用戶失??!"); }當(dāng)拋出異常時不回滾,比如正在插入的是id該是19,由于拋出異常,沒有插入,把異常去掉,插入數(shù)據(jù)的id是20.
添加回答
舉報
0/150
提交
取消