Suppose I have this ratio:
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 hierarchy-based inheritance matching for the Base, Sub1, Sub2 relationships, but using the Disciminator property from the Join class as a discriminator.
Here's a general idea for a mapping file:
<class name="Base" table="Base">
<id name="Id"><generator class="identity"/></id>
<discriminator />
<subclass name="Sub1" discriminator-value="1">...</subclass>
<subclass name="Sub2" discriminator-value="2">...</subclass>
</class>
Is there a way to accomplish something like this with <discriminator>, <join>or <many-to-one>? NHiberante seems to suggest that the discriminator is a column on this table (which makes sense to me .. I know this is unorthodox).
Thank.
source
share