Mapping OneToOne doesn't work for inherited members
Description
When mapping property by OneToOne to derived class, PropertyReference method of IOneToOneMapper throws exception:
Expected a member of NHibernate.Test.NHSpecificTest.NH1234.PersonDetail found the member NHibernate.Test.NHSpecificTest.NH1234.Person Person of NHibernate.Test.NHSpecificTest.NH1234.PersonDetailBase
Implementation of PropertyReference in class OneToOneMapper uses this condition,
if (_member != null && propertyInTheOtherSide.DeclaringType != _member.GetPropertyOrFieldType())
which doesn't work for members from base class mapped in derived classes.
Similar condititon is used in OneToManyMapper in method Class and I think that provides better solution and sloves situation that I described:
if (!collectionElementType.IsAssignableFrom(entityType))
Environment
None
Attachments
1
Activity
Show:
Alex Zaytsev May 13, 2013 at 1:53 PM
Port-back to 3.3.x as ad35d6bc6ab617d8e8bf72e00a58023120bdc2aa
Oskar Berggren October 20, 2012 at 4:13 PM
Definitely not "critical".
Alex Zaytsev October 2, 2012 at 4:08 PM
Thanks, fix commited to master 9d339f646296ade73c1b5041db3bca6fbde5188a
When mapping property by OneToOne to derived class, PropertyReference method of IOneToOneMapper throws exception:
Expected a member of NHibernate.Test.NHSpecificTest.NH1234.PersonDetail found the member NHibernate.Test.NHSpecificTest.NH1234.Person Person of NHibernate.Test.NHSpecificTest.NH1234.PersonDetailBase
Implementation of PropertyReference in class OneToOneMapper uses this condition,
if (_member != null && propertyInTheOtherSide.DeclaringType != _member.GetPropertyOrFieldType())
which doesn't work for members from base class mapped in derived classes.
Similar condititon is used in OneToManyMapper in method Class and I think that provides better solution and sloves situation that I described:
if (!collectionElementType.IsAssignableFrom(entityType))