O'Reilly logo

NHibernate 3 Beginner's Guide by Gabriel N. Schenker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The trouble with lazy loading

Lazy loading is a very handy feature that NHibernate offers to us, but if we are not careful enough this little feature can turn against us and cause our system to crawl. We might be surprised by the fact that to retrieve the data for a seemingly simple view can take a very long time, or in extreme cases time out.

Lazy loading is useful if we define a domain model where the different entities are related to each other via references or one to many associations. It was introduced to prevent NHibernate from always loading all associated entities when we only deal with one specific entity. Let's have a look at a simple blog engine. We have a Blog entity which has a collection of Post entities, as shown in the following ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required