In the beginning of the chapter we saw that when the Employee
entity was loaded, NHibernate did not load the associated collection entities such as Benefits
and Communities
. That is default behavior of NHibernate. At first it may sound strange, but think what would happen if NHibernate tried loading Benefits
and Communities
along with the Employee
entity. Each Community
instance in the Communities
collection has collection of the Employee
instances associated with it. NHibernate will need to load all those Employee
instances. Each of those Employee
instances will have further Community
instances to load. This cycle will only stop when the entire database is loaded into memory. To avoid situations like this, NHibernate only loads the entity that you asked for with all its primitive properties (or properties which are mapped to columns on the table of the entity) populated. Associated collection entities are loaded only when they are accessed. This feature is called lazy loading...
Learning NHibernate 4
Learning NHibernate 4
Overview of this book
Table of Contents (18 chapters)
Learning NHibernate 4
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
Introduction to NHibernate
Let's Build a Simple Application
Let's Tell NHibernate About Our Database
NHibernate Warm-up
Let's Store Some Data into the Database
Let's Retrieve Some Data from the Database
Optimizing the Data Access Layer
Using NHibernate in a Real-world Application
Advanced Data Access Patterns
Working with Legacy Database
A Whirlwind Tour of Other NHibernate Features
Index
Customer Reviews