I have an existing RoleType table with data. I am trying to map this table in NHibernate using Table per class hierarchy:
<class name="IRoleType" table="RoleType">
<id name="Id" column="RoleID">
<generator class="native" />
</id>
<discriminator column="RoleID" />
<property name="Description" column="Description" />
<!-- ... more properties ... -->
<subclass name="RoleA" discriminator-value="1" />
<subclass name="RoleB" discriminator-value="4" />
<subclass name="RoleC" discriminator-value="7" />
</class>
Here, IRoleType is an interface, with implementors RoleA, RoleB and RoleC. This works. But here's the problem -
The table contains rows with "extra" discriminator values (2,3,5,6) that are not mapped to a persistent class. These values are deprecated in the domain, so its not useful to create persistent class for each. But we also cannot delete them from the database.
Is there a way to map these extra rows to a single "default" class? If not, how else can I solve this problem?
Thanks!