Suppose I have this relationship:
abstract class Base { int Id; int JoinedId; ... }
class Joined { int Id; int Discriminator; ... }
class Sub1 : Base { ... }
class Sub2 : Base { ... }
for the following tables:
table Base ( Id int, JoinedId int, ... )
table Joined ( Id int, Discriminator int, ... )
I would like to set up a table-per-hierarchy inheritance mapping for the Base, Sub1, Sub2 relationships, but using the Disciminator property from the Joined class as the discriminator.
Here's the general idea for the mapping file:
<class name="Base" table="Base">
<id name="Id"><generator class="identity"/></id>
<discriminator /> <!-- ??? or <join> or <many-to-one>? -->
<subclass name="Sub1" discriminator-value="1">...</subclass>
<subclass name="Sub2" discriminator-value="2">...</subclass>
</class>
Is there any way of accomplishing something like this with the <discriminator>
, <join>
, or <many-to-one>
? NHiberante seems to assume the discriminator is a column on the given table (which makes sense to me.. I know this is unorthodox).
Thanks.