mysql 更新子查詢,mysql更新如果失敗怎么處理?
仔細點哦
Release r = dao.findRelease(releaseId); Book b = dao.findBook(bookId); if(r != null && b != null){ Session session = HibernateUtils.getSession(); Transaction tx = session.beginTransaction(); try{ dao.cancelBook(r, b); dao.updateReleaseCounts(r, b); }catch(Exception e){ tx.rollback(); } tx.commit(); }