<set> mapping using a property-ref as the link to its children can raise an InvalidCastException when loading
Description
Environment
None
Attachments
1
- 12 Jun 2013, 06:17 PM
Activity
Show:

Alex ZaytsevMay 1, 2017 at 3:42 AM
Closing issues resolved in 4.1.0

Jeff KeyserJune 19, 2013 at 1:16 PM
I have created a GitHub pull request (https://github.com/nhibernate/nhibernate-core/pull/211) with a proposed solution to this issue and NH-3453.
Who's Looking?
Scenario -
Parent element is mapped to child elements by a value other than the primary key of the parent, requiring the use of a "property-ref" attribute on the <key> element.
Parent ID property is of a different type than the value used for the mapping.
Intermittently, when loading the children of one of the parent elements, NHibernate will throw an InvalidCastException. Very specifically, it will throw this exception when the alternate value has a hash code that matches at least one parent ID already in the identity map. Attached is a test case that reproduces the issue. I created this using the latest code from GitHub.