I have a problem in NHibernate mapping. I have Class Company, Person and Address; Company and Person both can have Addresses hence i have taken Address in both. To store this I have tables Company, Person and Address. Now Company will have Address object and Person will also have Address Object so Address should also have reference to Company and Person object. So I created two child classes of Address 1. CompanyAddress 2. PersonAddress and in Database I created two more tables Company_Address and Person_Address. Now In Address.hbm.xml i have added Joined subclass for both CompanyAddress and PersonAddress which are referring to Company_Address and Person_Address tables respectively.
Now CompanyAddress class is having company object in it and PersonAddress class is having Person object in it.
Company_Address is having 2 columns AddressId(PK) and CompanyId(FK)->Company Person_Address is having 2 columns AddressId(PK) and PersonId(FK)->Person
I have created one-to-one mapping in Company.hbm.xml for Address. When i Save Company object every table is populating properly except Company_Address. AddressId is getting stored but CompanyId is not getting stored.
I have no idea how to get this working
If someone can faced this problem please help.
Thanks in advance!!! Pawan Shukla