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 almost got really confused when testing my
NHibernateUtil.IsInitialized(_myobject.MyCollection) resulted in false
but I saw the query to retrieve the collection in Profiler...


until I realized, I had added this collection to the Watch, same happened if I opened this collection in QuickWatch...otherwise, the collection is indeed lazy loaded.

Labels: ,