Bi-directional relationships are when you can access a relationship from
both sides.
// mono-directional
public class Store
{
  public IList<Product> Products { get; }
}

public class Product
{}

// mono-directional
public class Store
{}

public class Product
{
  public Store Store { get; }
}

// bi-directional
public class Store
{
  public IList<Product> Products { get; }
}

public class Product
{
  public Store Store { get; }
}

On Fri, Jul 3, 2009 at 9:40 PM, Cesar Sanz <[email protected]>wrote:

>
> Hello,
>
> What do you mean by biderectional? This topic is very interesting because
> this attribute
> is really hard to understand.
>
> Can you explain a little further?
>
> Thanks
> ----- Original Message -----
> From: "Roger" <[email protected]>
> To: "nhusers" <[email protected]>
> Sent: Wednesday, July 01, 2009 2:30 AM
> Subject: [nhusers] Re: What's the point of inverse=false?
>
>
>
> <<What I don't get is this: when would you NOT want to use
> inverse=true on a one-to-many relationship? >>
>
> In monodirectional relationships.
>
> I would guess the reason this is not "happening by default" in
> bidirectional one-to-many refs is to have consistent behaviour with
> other mappings such as many-to-many refs where you need to choose one
> side. I'm not sure though...
>
> To answer your question - if you have have a bidirectional one-to-many
> rel, always use inverse=true.
>
> /Roger
>
> On Jun 30, 2:49 pm, James Allen <[email protected]>
> wrote:
> > I have been trying to get to grips with Hibernate's inverse attribute,
> > and it seems to be just one of those things that is conceptually
> > difficult.
> >
> > The gist that I get is that when you have a parent entity (e.g.
> > Parent) that has a collection of Child objects using a one-to-many
> > mapping, setting inverse=true on the mapping tells Hibernate that 'the
> > other side (the Child) has responsibility to update itself to maintain
> > the foreign key reference in its table'.
> >
> > Doing this appears to have 2 benefits when it comes to adding Children
> > to the collection in your code, and then saving the Parent: you save
> > an unneccessary hit on the database (because without inverse set,
> > Hibernate thinks it has two places to update the FK relationship)
> > (seehttp://nhprof.com/Learn/Alert?name=SuperfluousManyToOneUpdate), and
> > according to the official docs:
> >
> > "If the column of a association is declared NOT NULL, NHibernate may
> > cause constraint violations when it creates or updates the
> > association. To prevent this problem, you must use a bidirectional
> > association with the many valued end (the set or bag) marked as
> > inverse="true"."
> >
> > This all seems to make sense so far. What I don't get is this: when
> > would you NOT want to use inverse=true on a one-to-many relationship?
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to