mysql LOCK TABLES 이후 트랜잭션 롤백이 불가능한 문제 해결

717 단어 데이터베이스
spring mvc + mybatis에서 하나의 사무를 정의했습니다. 사무는 서비스 층의 한 방법입니다.
try{

....
lock tables ...
}finally{
unlock tables...;
}

구덩이가 왔습니다. 이렇게 하면fun1이 굴러가지 않습니다. 해결은 Controller층에서 자물쇠를 방출하는 것입니다. 즉, 자물쇠 방출은fun1에서 방출할 수 없습니다.
예컨대
public ModelAndView handleRequest(HttpServletRequest req, HttpServletResponse resp) throws Exception {ModelAndView mav = new ModelAndView();Result result = new Result();try {result = upListService.updataListGoodsEx(code,goodsNumStr,goodsIdStr,teamIdStr,goodsPriceStr,user.getStructId());} catch (Exception e) {result.setMsg(e.getMessage());}finally {sfm.unlockTable(null);}return CheckUtil.returnResult(mav, result.getCode(), result.getMsg(), result.getData());}

좋은 웹페이지 즐겨찾기