Query the NHibernate session scope cache - NonUnique Exception
I'm having a problem in my application when I'm saving an entity. On occasion I'd get NonUnique exception on that entity from NHibernate. Now, I know what causes those kind of exceptions and how to deal with them, but since the application codebase is rather large (200K LOC), it's very hard to pinpoint which object it was exactly that caused that error.
What I'd like to do is query or extract somehow all the objects that NHibernate keeps in the session scope cache, so i'd have a better idea of what 开发者_如何学JAVAit was exactly that caused that exception.
Is there a way to do something like that ?
As far as I know there is nothing in ISession to "list" its contents. You could use interceptors or event listeners to track and log your operations though.
精彩评论