Skip to content

Fix property-ref on a component's property #1871

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

Conversation

fredericDelaporte
Copy link
Member

Fixes #1824

@@ -221,7 +221,7 @@ public string GetIdentifierPropertyName(string className)
public IType GetReferencedPropertyType(string className, string propertyName)
{
PersistentClass pc = GetPersistentClass(className);
Property prop = pc.GetProperty(propertyName);
Property prop = pc.GetReferencedProperty(propertyName);
Copy link
Member Author

Choose a reason for hiding this comment

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

GetProperty yields properties of the entity, it does not go inside components for yielding the component property.

@hazzik
Copy link
Member

hazzik commented Oct 13, 2018

@fredericDelaporte why does it show my name on the tests?

Copy link
Member

@hazzik hazzik left a comment

Choose a reason for hiding this comment

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

Looks correct

@hazzik
Copy link
Member

hazzik commented Oct 13, 2018

@fredericDelaporte can you check if #1214 is related?

@fredericDelaporte
Copy link
Member Author

fredericDelaporte commented Oct 13, 2018

@fredericDelaporte why does it show my name on the tests?

Because I have cherry-pick from your 4431485, squashed in it bab942a, then renamed the files and added the property triggering the failure and added a non-dynamic component for allowing checking it was also having the trouble.

@fredericDelaporte can you check if #1214 is related?

I tend to think no, but I will check the test case.

Update: the test case (90b9596) fails completely. It looks like some unrelated regression on property ref with many-to-many has happened since the test case was done.

@fredericDelaporte
Copy link
Member Author

fredericDelaporte commented Oct 13, 2018

#378 (NH v4.1, NH-3480) has broken #1214 case, which hinders me for diagnosing it.

Reverting #378 by keeping only the UseLHSPrimaryKey path here fixes #1214 previously working test.
By the way the UseLHSPrimaryKey path seems to do quite the opposite to what the property means. #378 causes the property-ref on the collection key column to be ignored when generating the insert SQL for the collection, using instead the primary key name of owner.
But for the failing one, the original reported failure is still not there after my partial local reversion of #378, and it looks to me due to some other #378 consequences I have not yet pinpointed (symptom: identifier value of ManyA is put in the many-to-many table instead of the referenced property value).

Update: a commit message has mislead me, mentioning #211 instead of #378 which has replaced it.

@hazzik
Copy link
Member

hazzik commented Oct 14, 2018

Because I have cherry-pick from your 4431485,

Ok.

Any reasons not to merge yet?

@fredericDelaporte
Copy link
Member Author

I was still investigating #1214. With #378 getting in the way, I have not yet ascertained it was not bound to the case fixed here, although it does still look unlikely to me.

@fredericDelaporte
Copy link
Member Author

fredericDelaporte commented Oct 15, 2018

#1214 root cause is a mapping error: using a property-ref on a property not flagged as unique. But NHibernate does not detect this error when validating mappings, and do not raise a good error when attempting to resolve an entity by an undeclared unique key.
So #1214 is not related.

Update: flagging the property as unique changes nothing, because that is not what uses NHibernate for enabling lookup by unique key. So it is not an user error in mapping, but a bug in NHibernate which should have flagged IsAlternateUniqueKey when compiling mappings.

@fredericDelaporte fredericDelaporte added this to the 5.2 milestone Oct 15, 2018
@fredericDelaporte fredericDelaporte merged commit 539a814 into nhibernate:master Oct 15, 2018
@fredericDelaporte fredericDelaporte deleted the propertyRefOnComponentProperty branch October 15, 2018 09:10
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