Skip to content

Unit test for issue #1766 #1768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Unit test for issue #1766 #1768

wants to merge 1 commit into from

Conversation

fubar-coder
Copy link
Contributor

This is a simplified version of NHibernate.Test.ListIndex.ListIndexFixture that uses an inverse list.

This unit test shows that an inverse list causes missing update statements to set the index column.

This is a simplified version of NHibernate.Test.ListIndex.ListIndexFixture that uses an inverse list.

foreach (var child in parent.Items)
{
child.A = parent;
Copy link
Member

@fredericDelaporte fredericDelaporte Jun 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The index has to be set here, like the parent. When a list is mapped as inverse, no update occurs from it. It may at most cascade the update/save operation if cascade is enabled, but it will not set the appropriate parent and index.

From here:

Changes made only to the inverse end of the association are not persisted.

The documentation also implies it with:

If there is a property of the child class that maps to the index column you can use inverse="true" on the collection mapping
...
If there is no such property on the child class, the association cannot be considered truly bidirectional. That is, there is information available at one end of the association that is not available at the other end. In this case, you cannot map the collection inverse="true".

This is so because once the collection is mapped as inverse, the index must be handled from the other side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok. So it was a misunderstanding on my side. Would it be possible to update/clarify the documentation for this use case and/or write a unit test that shows this behavior? I did expect the index column to always be set/updated, because it's an integral part of the list.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also:

The non-inverse side is used to save the in-memory representation to the database.

Anyway, a consequent update is also ongoing, awaiting review (see #1761). It notably adds some more examples and guidance, including some about lists.

I do not think we need to add more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants