日期:2014-05-20 浏览次数:20868 次
public String add() throws Exception { Transaction tx = null; Session session = null; try { session= countryRegionDAO.getSessionFactory().openSession(); tx=session.beginTransaction(); CountryRegion region=new CountryRegion(); region.setName(this.name); session.save(region); tx.commit();//-----------执行到这里抛出异常------- return "success"; } catch(Exception e) { if(tx != null) tx.rollback(); //e.printStackTrace(); } finally { session.close(); } return "fail"; }