Hi Rafael, To solve your problem you should add *fetch="join" *to the bag mapping.
But i don't think it's a good idea in general. The real solution for those situations is to create a query per use-case in which you define exactly which objects you want to load eagerly for a specific use-case. 2011/12/29 Rafael Mueller <[email protected]> > Hi, > > I got a parent mapping like this (http://pastie.org/3091773) > > <id name="Id"> > <column name="ID" length="36" /> > <generator class="assigned" /> > </id> > <bag cascade="none" inverse="true" lazy="false" name="Child1"> > <key> > <column name="PARENT_FK" /> > </key> > <one-to-many class="Child1" /> > </bag> > <bag cascade="none" inverse="false" lazy="false" name="Child2"> > <key> > <column name="PARENT_FK" /> > </key> > <one-to-many class="Child2" /> > </bag> > > When I try to load the parent, session.Get(parentId), NHibernate will > generate 3 queries, one for the parent, and another one for each child. > Thats the expected way to work? > > I dont want lazy-loading, since some people can mess up with N+1 selects, > but also I wanna be able to query a parent with all childs, when necessary > (so I need this mapping). > Theres any other way to solve this ? > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > -- Itzik Saban my blog <http://itziksaban.blogspot.com/> -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
