我在service層調(diào)用多個(gè)dao層方法,到用mybatis代理,其中一個(gè)出現(xiàn)問(wè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)拋出異常時(shí)不回滾,比如正在插入的是id該是19,由于拋出異常,沒(méi)有插入,把異常去掉,插入數(shù)據(jù)的id是20.
service層的事物無(wú)法回滾
尚方寶劍之說(shuō)
2018-10-12 15:26:47