0

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

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.

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.

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).

I am stumped.

3
  • Are you using SQLServer? Can you see what's going on using the profiler? Commented Jan 13, 2012 at 5:11
  • Yes, I already had show_sql on and the profiler shows no surprises. Looks fine. Commented Jan 13, 2012 at 6:20
  • Here's an odd thing. For all other types, the query is followed by running "exec sp_reset_connection" but not for the object type (Passenger) that eventually fails. Hmm. Commented Jan 13, 2012 at 6:29

1 Answer 1

0

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, the component worked in SQLite-based unit testing. It was only when shifting to SQL Server 2008 that it caused trouble.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.