我刚开始休眠 我想在迭代器中使用事务,所以我喜欢这样:
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
错误
怎么了!?;