NHibernate's criteria.List() hangs when lazy property exists on entity -


I am getting some strange behavior where NHibernate questions start to hang.

You can download this project

Here is the offending code:

  Public IList & lt; Post & gt; GetLatestLiveBlogEntries (Retrieve Intent Newentarios) {var maxDate = DateTime.Now; (Var Session = Session Manager. Open ()) {var crit = session.CreateCriteria (typeof (post)). Add (restriction. Ek ("enabled", true)) Add (Restrictions. Lt ("postDate", maxDate)). Orders (New Order ("Postdate", False)) // .SetFetchMode ("author", FetchMode.Eager) // & lt; - Exclusion of this line breaks everything! .SetMaxResults (numEntriesToRetrieve); StupidFileLogger.log ("If this is the last log, I am hanging on critics. List  ()"); Var listOfPosts = crit.List & lt; Post & gt; (); StupidFileLogger.log ("I was actually able to retrieve the posts"); Return Listoff Posts; }}  

is the main line. On the author's field .SetFetchMode on the first load of my demo project, it's fine. When I hit Refresh, it is hanging and never passes through critics. It works all the time with the list () call eager load.

I am using the castle. Capabilities Hibernate integration Component. To ensure 1 session report for session request.

The other strange thing I have found is that it only happens with SQL Server when I use SQLite, everything works fine. In my demo project I have a simple build flag that lets you db Allows easy switching of Just look at the / build directory.properties.xml

I think eager loading solves my problem in this particular case, but in my application I do not want to load anxious for everything.

Please download the solution and try for yourself. I have tried to do it on other machines and they do the same thing.

Here are some SQL Profiler captures. You can see that the query for the post was sent to the server, but it is closed there:

The first request (expected behavior) :

The second request (hangs):

Well, I think it's running on a windows server, so I know I do not know the equivalent of htop, but I bet you that there is a standoff somewhere in the database / session code And you should be able to see the thread status that each thread is in a waiting position.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -