Hello Hudson,

thanks for a very quick and good reply.

Your explanation is great!

I should be able to create the conventions with this new
"knowlegde" :)


Martin



On 5 Feb., 21:27, Hudson Akridge <hudson.akri...@gmail.com> wrote:
> > Basically it means that the other side of the join is the parent/owner of
> > the other object/s
>
> Not exactly (Read: no). The other side contains the information necessary to
> save the association. In a Parent/Child relationship context, that means the
> other side contains the reference back to the parent. In a RDBMS context,
> that means the child contains the FK field. If you think about it in more
> RDBMS terms, and not OO terms, it makes more sense.
>
> Here's my take on it:
> The Child object, needs to be written to the child table. The child table
> contains a Foreign Key that references the Parent table right? So your
> Children table would contain a ParentID column. That's what the Parents
> table joins to in a simple relationship.
>
> NHibernate can remove the terminology/use cases of RDBMS's, but only so far.
> In this case, Inverse is signifying that the Parent, does not actually
> contain a datapoint which will store a reference to children. That's
> contained by children. Therefore the child needs to save.
>
> In a ManyToMany situation, they're both technically "parents", that's why
> you need a join table between them. So one of them needs to be marked
> inverse. it doesn't matter which one (well, it technically does, but not in
> the 99% use case), just as long as only one of them is responsible for the
> saving. If both of their inverses are set to false, then they're both going
> to be contending for which side of the relationship is saving first, and
> you're going to end up with row contention.
>
> Inverse should be set on OneToMany's when the Child has a reference back to
> the parent (bi-directional). If the child does not have a reference back to
> the parent, then inverse should be false, signifying that the Parent now
> needs to manage the foreign key association with the child.
>
>
>
>
>
> On Fri, Feb 5, 2010 at 2:02 PM, Martin From <f...@pc.dk> wrote:
> > Hello,
>
> > i am trying to understand how Inverse() should be used and how it can
> > somehow work in a Convention for the different join types in fluent
> > nhibernate.
>
> > Does anyone have an example of a typical implementation of how to use
> > Inverse ? Or is there no typical pattern of how it should be used ?
>
> > I am having some difficulties figuring out how it should be used.
> > As I understand it, Inverse() assigns the resposibility of saving the
> > object to the other end of the join, which is also mentioned on the
> > Fluent Nhibernate Wiki. Basically it means that the other side of the
> > join is the parent/owner of the other object/s ?
>
> > As far as i have been able to find out Inverse is always set to
> > "false" on both sides per default in Hibernate, and it is not possible
> > to set Inverse on the Reference mapping. Is defaults different in
> > Fluent Nhibernate ?
> > I guess in most cases the side with the HasMany or HasManyToMany join
> > declaration is the one responsible for the other objects so Inverse
> > should be set on the Reference which is not possible (- clearly i dont
> > understand it correctly).
>
> > When looking at the example from "Getting Started" on the Fluent
> > Nhibernate page i get confused because Inverse() is set on the HasMany
> > join declared for the Property "Staff" in the Store mappings.
> > But looking at the database diagram the Employee (Staff) table have a
> > relation to the Store table through the foreign key Store_id, which
> > means that a Store needs to exist in order for the Employee to exist,
> > therefore in my mind the Store object should have the responsibility
> > of saving an Employee object.
>
> > Fluent Nhibernate - Getting Started -
> >http://wiki.fluentnhibernate.org/Getting_started#Mappings
>
> > I clearly must be misunderstanding something about Inverse.
> > Maybe it is the opposite of what i think? - That Inverse() should be
> > set on the side that is responsible of saving the objects in the other
> > end of the join ?
>
> > Or maybe it means something else ? :)
>
> > Martin
>
> > ps. i guess how Inverse() works is more a Hibernate related question,
> > but what i am trying to do is create a Fluent Nhibernate Convetion
> > using it "correctly".
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Fluent NHibernate" group.
> > To post to this group, send email to fluent-nhibern...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > fluent-nhibernate+unsubscr...@googlegroups.com<fluent-nhibernate%2bunsubscr­...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/fluent-nhibernate?hl=en.
>
> --
> - Hudsonhttp://www.bestguesstheory.comhttp://twitter.com/HudsonAkridge- Skjul 
> tekst i anførselstegn -
>
> - Vis tekst i anførselstegn -

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibern...@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to