Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the default behavior with Fluent NHibernate to lazy load HasMany<T> collections?

when I am setting up my fluent mappings, what is the default for collections? Do I need to explicitly set them as lazy-load, or is that the default?

like image 737
Kyle West Avatar asked Nov 25 '08 03:11

Kyle West


People also ask

What is lazy loading in NHibernate?

Any association, whether it be a many-to-one or a collection is lazy loaded by default, it requires an Open ISession. If you have closed your session, or if you have committed your transaction, you can get a lazy load exception that it cannot pull in those additional objects.

What is lazy load database?

Lazy loading is the process whereby an entity or collection of entities is automatically loaded from the database the first time that a property referring to the entity/entities is accessed. Lazy loading means delaying the loading of related data, until you specifically request for it.

What is fetch in NHibernate?

A fetching strategy is the strategy NHibernate will use for retrieving associated objects if the application needs to navigate the association. Fetch strategies may be declared in the O/R mapping metadata, or overridden by a particular HQL or Criteria query.


1 Answers

Note this is changed as of current day to be inline with NHibernate standards which is lazy loading is enabled by default for everything.

like image 113
Chris Marisic Avatar answered Sep 24 '22 12:09

Chris Marisic