事务未在hibernate中成功启动

时间:2014-06-10 08:54:36

标签: hibernate jpa

我刚开始休眠 我想在迭代器中使用事务,所以我喜欢这样:

Session session = opensession();
Transaction tx = session.beginTransaction();
for {
    try {
        something = session.get;
        something.setX = X;
        session.save(something)
        tx.commit(); <-- error occurs after iterated once.
    catch { tx.rollback(); }
}
something2 = session.get;
something2.setX = X;
session.save(something2);
tx.commit():
session.close();

但是hibernate发生Transaction not successfully started错误 怎么了!?;

0 个答案:

没有答案