Well, between me and the official docs, I wouldn't bet a single cent on myself :-D (It wouldn't be the first time I'm dead wrong...)
In any case, it's not hard to do a proof of concept (which I usually do when in doubt, but it's one of those mondays...). Maybe the problem is with many-to-many, or he's not adding on the "inverse" side. Diego On Mon, Feb 22, 2010 at 15:14, cliff vaughn <[email protected]>wrote: > Diego, > > I'm a little confused by your answer, because the NHibernate docs say this: > > 14.1.3. Bags and lists are the most efficient inverse collections > > Just before you ditch bags forever, there is a particular case in which > bags (and also lists) are much more performant than sets. For a collection > with inverse="true" (the standard bidirectional one-to-many relationship > idiom, for example) we can add elements to a bag or list without needing to > initialize (fetch) the bag elements! This is because IList.Add() or > IList.AddRange() must always succeed for a bag or IList (unlike a Set). > This can make the following common code much faster. > > Parent p = (Parent) sess.Load(typeof(Parent), id); > Child c = new Child(); > c.Parent = p; > p.Children.Add(c); //no need to fetch the collection! > sess.Flush(); > > > Which of you is correct? > > thanks > > cliff > > On Mon, Feb 22, 2010 at 10:46 PM, Diego Mijelshon > <[email protected]>wrote: > >> If you access the collection, it WILL be loaded (otherwise, the in-memory >> model would have an inconsistency) >> With one-to-many+many-to-one on the other side, it's easy to do, you just >> create the relationship on the other side (the one that has many-to-one. >> With many-to-many, well, you could choose the side that has less elements >> to work from, or refactor the relationship into two one-to-many collections >> with an intermediate entity, so you can just create instances of that >> entity. >> In any case... you should do these things ONLY if you are experiencing >> perfomance problems because of the collection load. Are you? >> >> Diego >> >> >> >> On Mon, Feb 22, 2010 at 13:53, Jonathan Curtis < >> [email protected]> wrote: >> >>> We have a entity with a many-to-many collection mapped as a lazy >>> loaded bag. When we load up the entity, the collection is not loaded - >>> great. Now we want to add a new entity to that collection. As soon as >>> we do this, the collection is loaded up. >>> >>> How do we add the new entity without loading up the whole collection >>> (the collection is large)? >>> >>> -- >>> 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]<nhusers%[email protected]> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/nhusers?hl=en. >>> >>> >> -- >> 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]<nhusers%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/nhusers?hl=en. >> > > > > -- > thanks > > cliff > > -- > 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]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > -- 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.
