Page 1 of 1

Inverse option for 1:many relationships

Posted: Thu 19 Jan 2012 16:17
by mindplay
Just a quick question, hopefully.

When you define a one-to-many relationships, why is there an option to disable "inverse" on the many-side of the relationship?

As far as my understanding of NH, with a one-to-many relationship resulting in two "relationship definitions" in terms of the generated HBM mappings, the "inverse" option should always be used on the reverse relationship, since, the way the schema is generated, the many-side is always the "owner" of that relationship, since that's where the foreign key is located in the schema.

Is there a real use-case for a one-to-many where the many-side is not "inverse"?

The only use-case I can think of, is a one-to-many where the one-side isn't generated.

If that is the only use-case, why doesn't the "generate" setting simply drive the "inverse" property? At least, it could automatically set the "inverse" property to the most likely default, or not?

Posted: Mon 23 Jan 2012 18:00
by Shalex
Here are cases when Inverse=True should be used:
http://www.nhforge.org/doc/nh/en/index. ... -onetomany
http://www.nhforge.org/doc/nh/en/index. ... irectional
http://www.nhforge.org/doc/nh/en/index. ... ypes-bidir

By default, Inverse is set to False - we consider this behaviour as correct.

Posted: Mon 23 Jan 2012 20:08
by mindplay
From the section on bi-directional associations:
The non-inverse side is used to save the in-memory representation to the database. We would get an unneccessary INSERT/UPDATE and probably even a foreign key violation if both would trigger changes! The same is of course also true for bidirectional one-to-many associations.
It's my understanding that one end of any bi-directional relationship, as a rule, should be set as inverse.

So I still don't understand why marking one side of a bi-directional one-to-many as inverse is optional in ED - I don't think it's allowed? (or if it is allowed, it must be a pretty exotic case - I don't think I've seen an example where such a configuration was required, so it's a bit hard to understand why it would be the default... for many-to-many relationships, marking one end as inverse is enforced by ED.)

Posted: Tue 24 Jan 2012 10:24
by Shalex
We are investigating the issue.

Posted: Fri 27 Jan 2012 13:29
by Shalex
The behaviour will be changed starting from the next public build of Entity Developer: the Inverse option on the many-side of a one-to-many relationship will be set to True by default.

Posted: Fri 10 Feb 2012 12:10
by Shalex
New build of Entity Developer 4.2.129 is available for download now!
It can be downloaded from http://www.devart.com/entitydeveloper/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=23375 .

Re: Inverse option for 1:many relationships

Posted: Mon 08 Apr 2013 12:19
by mindplay
You're over a year late with these updates, folks - I have long since moved on and no plans to ever use this software again.

Re: Inverse option for 1:many relationships

Posted: Tue 09 Apr 2013 08:24
by Shalex
mindplay wrote:You're over a year late with these updates
Build 4.2.129 with the functionality you had requested was released on February 9, 2012: http://www.devart.com/entitydeveloper/r ... story.html.

Re: Inverse option for 1:many relationships

Posted: Tue 09 Apr 2013 13:02
by mindplay
I see the date on the post, yes - very strange. I received this and five other e-mail notifications yesterday, a year after you posted them, so maybe you've got a problem with your forum...

Re: Inverse option for 1:many relationships

Posted: Thu 11 Apr 2013 07:45
by Shalex
There were a lot of spam posts (which have already been removed) at out forum in different threads. Most likely you received notifications about spam posts.