Simple question: does it matter which side of a bidirectional many-to-many relationship you set as the inverse in NHibernate? And if so, what are the implications of setting it on one end vs. the other?
Some more clarification: I’m setting both sides of the relationship:
Parent.Children.Add(child);
Child.Parents.Add(parent);
In a case like this, does it matter which side I mark as inverse?
Yes it matters, changes made only to the inverse end of the association are not persisted
You may check nhibernate documentation for further details. Here you have the link:
http://www.nhforge.org/doc/nh/en/#collections-bidirectional
EDIT
My answer doesn’t change with your addition, but I’ll try to explain it better 🙂
if you set Parent.Children with
inverse = trueyou need to save Child object in order to save the relation. If you ONLY save Parent then the relation won’t be savedif you set Child.Parent with
inverse = trueyou need to save Parent object in order to save the relation. If you ONLY save Child then the relation won’t be saved