请问hibernate异常nested transactions not supported这个错怎么解决呢
创建了一个数据库,dao层用了下面这个函数:@Overridepublicvoidadd(Objectobj)throwsException{Sessionsession...
创建了一个数据库,dao层用了下面这个函数:
@Override
public void add(Object obj) throws Exception {
Session session = null;
try {
session = sessionFactory.openSession();// .getSession();
session.save(obj);
session.beginTransaction().commit();
if (session != null) {
session.close();
}
} catch (RuntimeException e) {
session.beginTransaction().rollback();
if (session != null) {
session.close();
}
throw e;
}
}
报错:
nested exception is org.hibernate.TransactionException: nested transactions not supported] with root cause
请问是怎么回事呢 展开
@Override
public void add(Object obj) throws Exception {
Session session = null;
try {
session = sessionFactory.openSession();// .getSession();
session.save(obj);
session.beginTransaction().commit();
if (session != null) {
session.close();
}
} catch (RuntimeException e) {
session.beginTransaction().rollback();
if (session != null) {
session.close();
}
throw e;
}
}
报错:
nested exception is org.hibernate.TransactionException: nested transactions not supported] with root cause
请问是怎么回事呢 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询