Inverse option for 1:many relationships

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
mindplay
Posts: 148
Joined: Tue 13 Dec 2011 22:58
Location: Ithaca, NY

Inverse option for 1:many relationships

Post by mindplay » Thu 19 Jan 2012 16:17

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?

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 23 Jan 2012 18:00

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.

mindplay
Posts: 148
Joined: Tue 13 Dec 2011 22:58
Location: Ithaca, NY

Post by mindplay » Mon 23 Jan 2012 20:08

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.)

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 24 Jan 2012 10:24

We are investigating the issue.

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 27 Jan 2012 13:29

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.

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 10 Feb 2012 12:10

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 .

mindplay
Posts: 148
Joined: Tue 13 Dec 2011 22:58
Location: Ithaca, NY

Re: Inverse option for 1:many relationships

Post by mindplay » Mon 08 Apr 2013 12:19

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.

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Re: Inverse option for 1:many relationships

Post by Shalex » Tue 09 Apr 2013 08:24

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.

mindplay
Posts: 148
Joined: Tue 13 Dec 2011 22:58
Location: Ithaca, NY

Re: Inverse option for 1:many relationships

Post by mindplay » Tue 09 Apr 2013 13:02

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

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Re: Inverse option for 1:many relationships

Post by Shalex » Thu 11 Apr 2013 07:45

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.

Post Reply