-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Learning NHibernate 4
By :
Lazy loading is about "when associated entities are loaded". There is another angle to loading associated entities which is about "how associated entities are loaded". The latter is controlled by a feature called fetching strategy. A simple example here would help. Suppose you want to retrieve all benefit records for a particular employee. There are different ways of doing this. For instance, following are two different SQL queries that I can think of to retrieve benefit records:
You can use a join between Employee and Benefit table
You can just select from the Benefit table using a WHERE clause that limits the records by matching foreign key column Employee_Id to the ID of the employee record
NHibernate supports three different ways of fetching associations. Through fetching strategy you can tell NHibernate which way it should use for a particular association. From optimization point of view, this is a good lever to use. Fetching strategy is declared as part of mapping...