Hibernate报异常“nested transactions not supported“,这怎么解决啊?
public boolean saveFilmInfo(FilmInfo info) {
boolean flag = false;
Transaction tx = null;
try {
tx = getSession().beginTransaction();
getSession().save(info);
tx.commit();
flag = true;
} catch (Exception e) {
// TODO: handle exception
tx.rollback();
e.printStackTrace();
}
return flag;
}
运行到tx = getSession().beginTransaction();这里时就报异常为:
org.hibernate.TransactionException: nested transactions not supported
怎么回事啊,搞不懂了。其它就没问题
------解决方案--------------------事务嵌套了?
------解决方案--------------------
tx = getSession().beginTransaction();
改成
tx = getSession().beginTransaction()
.begin();
------解决方案--------------------
我傻X了、
是这样的
tx = getSession().beginTransaction();//获取事务
tx.begin(); //开启事务