-
Notifications
You must be signed in to change notification settings - Fork 934
Unable to correctly resolve the owner key with null value property #1983
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
Comments
Which way is it? Does it throw if the referenced entity has the property null, or if the referencing entity has its association null? |
It throws if the referencing entity has a property with null. In the example, it would be "Property" that is null and throws the exception when we access someEntity.SomeChildrenList. |
Considering this case again, it seems to me that somewhat supporting Associating entities with a So this could be fixed in two ways:
|
thanks for investigating. For me, readonly access would be enough as I can't have a ForeignKey for different reasons. So if the property ref is null and empty (or null) collection is returned. That worked in previous releases and would be a non breaking change. |
The more I consider this, the more I think we should:
From a correctness standpoint, there is no point introducing back a bugged behavior, where one could access a non-functional collection without having any error raised, although anything done on the collection was ignored. That breaks the least surprise principle. When something does not work, it should throw, rather than silently do nothing. This means for your case that you have to check your referenced property before accessing the collection : if it is |
Now documented as a possible breaking change, see here. |
I had a string column that was used to group entities, and the group of associated entities was loaded via property-ref as an immutable collection, so updating to the 5.2 series broke this. I worked around it by setting the column to '' for all pre-existing null entries, and then add a |
I am running into the same issue. I have one to many mapping and referencing the second table column via property ref. The referring entity from the parent table has null values. there are no foreign keys. This started breaking after I upgraded to nhiberante 5.3. Is there any work around for this? |
If your have a
|
Since NHibernate version 5.2 (commit: 8124cb5)
GetKeyOfOwner
in CollectionType.cs throws an exception if the property value (in the database) is null.Exception:
Mapping (Example.SomeEntity):
There is no ForeignKeyConstraint on Property and ReferencedProperty and both properties are not keys.
The text was updated successfully, but these errors were encountered: