Fetching strategies


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 ...

Get Learning NHibernate 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.