开发者

Which collection causes the NHibernate exception?

I'm getting the well known NHibernate exception "Illegal attempt to associate a collection with two open sessions". I did research on it, and I understand the cause of it, but my problem is that it occurs randomly in the field, when I'm unable to 开发者_开发百科debug it.

My question is, is there someway to query the exception or the current NH state, to figure out which collection or object causes this ?

BTW, I did manage to inherit from SessionScope, and override some of the functions to add logging to it, but it doesn't help me with the exception itself.


Attaching debugger when exceptions is thrown can give you a hint at what collection is causing this. You probably saving a particular object so you can just try to deduct what collection it references. If that does not help, you can try to find instance of NHibernate session. Once you found it in debugger you can look at session.Statistics.EntityKeys and CollectionKeys. These are the internal structures that NHibernate uses for tracking objects. Hope it helps...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜