I guess the primary issue is that if you do a bidirectional association you
need to keep in mind that the other end of the association (from the one
that's being modified) is not automatically updated so you need to add the
logic to manage this yourself.

For example, take the ubiquitous example of an Order class with an
OrderLines collection which contains instances of the OrderLine class, which
in turn has has an Order property.

What happens when you create a new OrderLine object?

If you set the Order property of the OrderLine instance and you've mapped a
bidirectional association in your mapping where the collection end is mapped
as inverse so it's not in control of the association the data in the
database will be correct and when you load your Order or OrderLine both ends
of the association are correct.

The problem, however is before you save and reload the changes using
NHibernate - the association in memory is not automatically handled so the
Order instance's OrderLines collection will not contain the new OrderLine
unless you explicitly add it yourself in your code.

That's the primary reason I think most people avoid bidirectional
associations - if it's appropriate for you to use then use it, just be aware
of the extra work involved that NHibernate won't do for you.

Cheers,

Symon.

On Tue, Oct 21, 2008 at 5:58 PM, Tim Barcz <[EMAIL PROTECTED]> wrote:

> I'm hearing and reading different things....is unidirectional or
> bidirectional the recommended way.
>
> On certain scenarios I don't need to go unidirectional but then have a hard
> time mapping but then see people say unidirectional is bad.
>
> Which is it?  Uni or Bi?
>
> >
>


-- 
Symon Rottem
http://blog.symbiotic-development.com

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