Hi, I do not know what is happening in your case, I just know I do solve N+1 troubles in quite an other way, which may be better suited for your case. You are trying to eager fetch your dependent entity, disabling lazy loading. I generally would rather tell NHibernate to batch the dependent entity lazy loading. Say you have loaded in your NHibernate session a bunch of entities "A", which all have a "B" entity property, lazily loaded. Batching lazy loading means that Nhibernate will not only lazy load one "B" entity upon first B property access on a "A" entity, but it will also load a bunch of other "B" entities of the "A" entities.
For your case, you enable batching by adding "batch-size" attribute on your class mapping declaration for "AnotherClass"'. You should specify as value the size of the batch you wish. Batching can also be enabled for properties being collection of entities. The attribute "batch-size" is then to be added on the collection mapping declaration. Batching on collection is quite similar, it means that accessing a mapped collection property will not only load the collection for the entity owning the property, but also for other entities of the same classes that are already loaded in the NHibernate session. Regards. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/groups/opt_out.
