Connection conn = session.connection(); Object result = null; Transaction transaction = null; try { transaction = session.beginTransaction(); try { result = callback.doInTransaction(conn); } catch (RuntimeException ex) { doRollback(session, transaction); throw ex; } catch (Error err) { doRollback(session, transaction); throw err; } transaction.commit(); } catch (WorkflowException e) { logger.error("数据库操作失败,事务回滚也失败!"); throw e; } catch (RuntimeException ex) { logger.error("数据库操作失败,事务被回滚!"); throw ex; } catch (Error err) { logger.error("数据库操作失败,事务被回滚!"); throw err; |