日期:2014-05-20  浏览次数:21771 次

关于Nhibernate的异常Transaction not connected, or was disconnected
我用Fluent hibernate 框架写的一个程序,每天自动下发或上传数据用。经常报这个错误,比如上传成功200条,失败5条数据,其中异常:Transaction not connected, or was disconnected。网上搜的资料,有的人说是回滚超时,Nhibernate报的这个异常。如果说是回滚异常,不知道为什么会导致回滚异常。因为我写的很多接口比如005,007,006三个接口。处理提交,回滚的代码如下。其他接口都没出现回滚异常,独独007出现回滚异常?求大神们指导,帮帮忙!这到底是什么问题,是回滚超时异常,还是其他原因?求具体解决办法!
 using (ITransaction tx = _session.BeginTransaction())
  {
  try
  {
  item.Save(_session);
  _session.Flush();
  _session.Clear();
  tx.Commit();
  return true;
  }
  catch (Exception e)
  {
  tx.Rollback();
  _session.Clear();
  throw new DataAccessException(e.ToString().Split(new char[] { '\n' })[0]);
  }
------解决方案--------------------
自己顶一下