代码模板-1

		Session session = HibernateSessionFactory.getSession();
		Transaction transaction=null;
		try {
			transaction = session.beginTransaction();
			transaction.begin();
			//操作
			transaction.commit();
		} catch (Exception e) {
			//日志
			if(transaction!=null){
				transaction.rollback();
			}
			throw e;
		}finally{
			session.close();
		}
 

你可能感兴趣的:(代码)