NHibernate with Interface Oriented Programming
Hibernate does not check the property's claimed type. It will always work as long as the object pass to it is assignable to the type NHibernate expect.
This is very important to Interface oriented programming with Hibernate.
The following code works:
<class name="Husband, Domain" table="tbHusband">
<id name="m_Id" access="field" type="Int32" column="HusbandId" unsaved-value="0">
</class>
<class name="Wife, Domain" table="tblWife">
<many-to-one name="Husband" class="Husband, Domain" column="Husband_HusbandId" unique="true" />
</class>
public class Wife : IWife
{
private IHusband m_Husband;
public IHusband Husband
{
get{return m_Husband;}
set{m_Husband = value;}
}
}
public interface IHusband
{
}
public class IHusband
{
}
here is a topic about this pattern
http://forum.hibernate.org/viewtopic.php?t=953412&start=0&postdays=0&postorder=asc&highlight=