我是一個新手休眠。請讓我知道下面的代碼中有什麼錯誤?hibernate begintransaction拋出異常
f1()
{
try {
s = HibernateUtils.getSessionFactory().getCurrentSession();
tx = s.beginTransaction();
// do some task
tx.commit();
} catch(Exception e) {
tx.rollback();
throw e;
}
}
f2()
{
try {
s = HibernateUtils.getSessionFactory().getCurrentSession();
tx = s.beginTransaction();
f1();
tx.commit();
} catch(Exception e) {
tx.rollback();
}
}
f1()中的begin transaction語句拋出異常。提前致謝。
什麼例外.. ??/ –
不支持嵌套事務。 – Varun
通過調用openSession()而不是使用當前會話來創建一個新的會話來解決它。不管怎麼說,多謝拉。 – Varun