the second property:
Code:
<many-to-one name="Owner" column="InvestorId" class="Owner" />
Is for the association back to the parent object, and its in the Hibernate documentation
http://www.hibernate.org/hib_docs/reference/en/html/inheritance.html.
Otherwise how can i create a row in the subclass table and associate its PKFK back to the row in the parent class table?
I kind of came up with a work around, by creating another class and adding a one-to-one mapping between the new class and my parent class. The mapping file is below:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="OwnerInvestor" table="Investor">
<id name="Id" column="InvestorId" type="Guid" unsaved-value="00000000-0000-0000-0000-000000000000">
<generator class="foreign">
<param name="property">Owner</param>
</generator>
</id>
<one-to-one name="Owner" class="Owner" constrained="true" />
</class>
</hibernate-mapping>
Now if I do:
Code:
OwnerInvestor ownerInvestor = new OwnerInvestor();
ownerInvestor.Owner = owner;
Save(ownerInvestor);
I just created my association back to my parent object. Its very messy though.
Theretically, now I can retreive my Investor object like normal, but I'm getting this error:
Quote:
(loading object was of wrong class)
which is probably a totally different error all together.