开启事务之前先判断事务是否已经打开,方法如下:
JdbcTransaction tx=(JdbcTransaction) session.beginTransaction();
改为
JdbcTransaction tx = session.getTransaction().getLocalStatus()==LocalStatus.ACTIVE?(JdbcTransaction)session.getTransaction():(JdbcTransaction) session.beginTransaction();