Skip to content

Fix many-to-many with property-ref #1873

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

Merged

Conversation

fredericDelaporte
Copy link
Member

@fredericDelaporte fredericDelaporte commented Oct 15, 2018

Fixes the second bug causing #1214.

@@ -131,7 +131,7 @@ bei System.ThrowHelper.ThrowKeyNotFoundException()
bei NHibernate.Type.EntityType.LoadByUniqueKey(String entityName, String uniqueKeyPropertyName, Object key, ISessionImplementor session) in C:\Users\Armin\Projects\NHibernate\branches\2.1.x\nhibernate\src\NHibernate\Type\EntityType.cs:Zeile 552.
*/

Assert.That(loadedManyA.ManyBs.Count, Is.EqualTo(3));
Assert.That(loadedManyA.ManyBs, Has.Count.EqualTo(3).And.None.Null);
Copy link
Member Author

Choose a reason for hiding this comment

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

And.None.Null is required because there was two bugs: one causing an exception (the reported one) and another one, prevented by the failure, causing the children to be null with this test case.

{
manyToMany.ReferencedPropertyName = manyToManyMapping.propertyref;
mappings.AddUniquePropertyReference(manyToMany.ReferencedEntityName, manyToMany.ReferencedPropertyName);
Copy link
Member Author

Choose a reason for hiding this comment

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

Root cause of the reported bug: a many-to-many rhs is like a one-to-many and like an actual one-to-many, it needs to promote the property-ref as a unique property reference for allowing the loader to eager load it.

// 6.0 TODO: consider breaking again that IJoinable.SelectFragment interface for transmitting
// the OuterJoinableAssociation instead of its Joinable property. This would allow to get the
// adequate columns directly instead of re-computing them.
: ((IPropertyMapping) rhs).ToColumns(elementType.RHSUniqueKeyPropertyName);
Copy link
Member Author

Choose a reason for hiding this comment

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

Fix of the additional bug, see all the comments added in code for the rational.

@fredericDelaporte
Copy link
Member Author

The other PR on which it was relying is merged, and this PR has been rebased, and is ready for review.

@fredericDelaporte
Copy link
Member Author

This one is not in the 5.2 milestone yet, but I consider this as a follow up to #1872, and would rather have it in.

So,

As proposed on the development group, and since no continued grounded disagreement has been expressed there since one week after raised concerns being addressed, I intend to merge this PR next week (likely on Wednesday).

(I am issuing this notice on PR issued before starting to apply this handling of merges. I will not do it for new PR.)

@hazzik
Copy link
Member

hazzik commented Oct 30, 2018

Reviewing a PR which is built on top of (includes) another is really painful as it is not clear what has changed. I'll review it now.

@fredericDelaporte fredericDelaporte merged commit 385a861 into nhibernate:master Oct 31, 2018
@fredericDelaporte fredericDelaporte deleted the many-to-many-prop-ref branch October 31, 2018 16:37
@fredericDelaporte fredericDelaporte added this to the 5.2 milestone Oct 31, 2018
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