Monday, August 25, 2008

Adding an NHibernate collection to your QuickWatch initializes it

I spent most of the day trying to improve performance on an application. We use NHibernate 2.0 and try to lazy load most of the collections.
I found these two links very useful for troubleshooting my performance issue:
http://djeeg.blogspot.com/2006/08/nhibernateutilisinitialized.html
and the NHibernate reference:
http://www.hibernate.org/hib_docs/nhibernate/html/performance.html

The curious thing is I got really confused when testing my
NHibernateUtil.IsInitialized(_myobject.MyCollection) line and it was false
but I saw a query retrieving the collection in Profiler...


until I realized that adding the collection to the Watch initializes it. The same happens if you open this collection in QuickWatch. :-p

Labels: ,