views:

101

answers:

1

I've got a two tables that i'm trying to map. Table1 has a many-to-one relationship with Table2 via the FK, fk_table2_id.

In table1's mapping I also have a discriminator and a subclass defined, like so:

<class name="MyAssembly.MyClass1, MyAssembly" table="table1" discriminator-value="null">
<discriminator column="fk_table2_id" type="int"/>

<many-to-one name="Category" class="MyAssembly.MyClass2, MyAssembly" column="fk_table2_id"/>

<subclass name="MyAssembly.MyDerivedClass1, MyAssembly" discriminator-value="1"/>

When trying to save MyClass1/MyClass2, I get the following error:

SetUp : System.ArgumentOutOfRangeException : Index was out of range. Must be non-negative and less than the size of the collection.

Parameter name: index

Now I'm pretty sure it has to do with the fact that I'm using one column for both the discriminator and the relationship. Is this really a limitation? How do I get around it?

+1  A: 

I think I got the workaround in case anyone else needs it:

<discriminator type="int" formula="fk_table2_id"/>
legion