NHibernate延迟加载操作失败 [英] NHibernate failing on deferred load action

查看:139
本文介绍了NHibernate延迟加载操作失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从存储库中获取相同类型的(快速连续的)第三个对象时,我看到以下错误.最初的获取成功,但是当我返回以获取详细信息时,剩下的负载就发生了,我看到了.

I am seeing the following error when I get the third object of the same type (in rapid succession) from the respository. The initial get succeeds but when I go back to get the details, the rest of the load happens and I see this.

NHibernate.Exceptions.GenericADOException: could not load an entity

我已经遍历了所有数据,而第三项完全没有任何奇怪之处.它及其所有引用的对象都是完全正常的.但是,该问题是一致的,因此可能不是时间问题.其他对象成功使用相同的Session对象.

I have been all over the data and there is nothing odd about the third item at all. It is perfectly normal as are all its referenced objects. The problem, however is consistent and so probably not a timing issue. Other objects using the same Session object successfully.

我同时也在NHibernate日志中看到以下内容:

I also see the following in the NHibernate log at the same time:

NHibernate.Util.ADOExceptionReporter System.InvalidOperationException: Invalid attempt to call MetaData when reader is closed.

根据我对这个错误的研究,这意味着NHibernate在遍历最后返回的行之后尝试使用阅读器.但是,由于行是由NHibernate本身的初始get生成的(现在随着延迟的读取而变得充实),因此我看不到怎么发生.

According to my research of this error, it means that NHibernate has tried to use a reader after it iterated past the last returned row. However, I do not see how that could happen because the rows were generated by the initial get from NHibernate itself (which it is now fleshing out with the deferred read).

我很困惑.

推荐答案

我们找到了罪魁祸首. Passenger类是使用组件映射的.这些组件之一指定了CustomType.当该组件被注释掉时,问题就消失了.还原组件后,问题再次出现.

We have found the culprit. The Passenger class was mapped using Components. One of those components specified a CustomType. When that component was commented out, the problems went away. When the component was restored, the problem returned.

目前,这将作为解决方法.

For now, that will serve as a work-around.

BTW,该组件在基于SQLite的单元测试中起作用.只是当使用SQL Server 2008时才引起麻烦.

BTW, the component worked in SQLite-based unit testing. It was only when shifting to SQL Server 2008 that it caused trouble.

这篇关于NHibernate延迟加载操作失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆