Tnx @TigerSgark for your help. I just wanna insure to get your right. your mean when I put inverse() in my mapping it means that this class in parent and first this class must be saved and then their child collections ?
On Thursday, May 13, 2010 7:58:03 PM UTC+4:30, TigerShark wrote: > > Inverse has to do with the way NHibernate treats inserts and updates. > With inverse set to true, you are defining the "other" side of the > relation as the owner. > It is very confusing and hard to understand, unless you do some tests > with inserts. > > With a collection, you can tell NHibernate to, as you did, cascade the > updates and inserts. > If you are inserting an entity in a collection and saving the class > containing the collection, NHibernate can do one of two things. > > 1. insert parent and then insert the child (inverse true), or > 2. insert the child, insert the parent, update the foreign key of the > child (inverse false) > > It all depends on your mapping and object model, but just remember > that by defining inverse, you define which side of the relationship > that "owns" it. > > You can also find a lot of information regarding this on Google :) > Check also > http://stackoverflow.com/questions/713637/inverse-attribute-in-nhibernate > > > Kenneth > > On 12 Maj, 18:33, Nabeel <nabeelfa...@gmail.com> wrote: > > Hi guys, > > > > I am exploring Fluet NHibernate and I have not used NHibernate before. > > I would like to know what is the purpose of Inverse() method. > > > > In the example on wiki. it is stated > > > > "Inverse on HasMany is an NHibernate term, and it means that the other > > end of the relationship is responsible for saving." > > > > But even if I remove the Inverse() from the StoreMap in the following > > statement > > > > HasMany(x => x.Staff) > > .Inverse() > > .Cascade.All(); > > > > it still works and generate the same sql. > > > > Also, Store has one-to-many on Employee, so how come employee be > > responsible for saving itself? It needs a StoreId as its foreign key > > rite, so it should be the other way round i.e. Store should be > > responsible for saving employee ? > > > > I am lost? The strange thing is even after removing it, the example > > works as it is. > > > > -- > > You received this message because you are subscribed to the Google > Groups "Fluent NHibernate" group. > > To post to this group, send email to fluent-n...@googlegroups.com > <javascript:>. > > To unsubscribe from this group, send email to > fluent-nhibern...@googlegroups.com <javascript:>. > > For more options, visit this group athttp:// > groups.google.com/group/fluent-nhibernate?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Fluent NHibernate" group. > To post to this group, send email to fluent-n...@googlegroups.com > <javascript:>. > To unsubscribe from this group, send email to > fluent-nhibern...@googlegroups.com <javascript:>. > For more options, visit this group at > http://groups.google.com/group/fluent-nhibernate?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To unsubscribe from this group and stop receiving emails from it, send an email to fluent-nhibernate+unsubscr...@googlegroups.com. To post to this group, send email to fluent-nhibernate@googlegroups.com. Visit this group at http://groups.google.com/group/fluent-nhibernate. For more options, visit https://groups.google.com/d/optout.