(I'm on the same project as Lasse)
Our problem is that we have a legacy database which we cannot easily change.
Code:
<!-- adding this to the mapping file causes the exception be thrown -->
<many-to-one name="appointedRole" class="AppointedRole" column="APPOINTEDROLE">
<key name="type" column="TYPE_COLUMN_IN_THIS_TABLE"/>
<key name="id" column="ID_COLUMN_IN_THIS_TABLE" />
</many-to-one>
</component>
Additionally, it should not be necessary to specify the "type" column, because we are referring to an instance of a subclass and it is sufficient to merely reference the subclass-specific id from the "candidate" table. Indeed, we realize that Hibernate does of course actually ultimately require values for
both of the columns in the 2-column composite id of the subclass table, but the
other value can be directly found as the "discriminator" value of the AppointedRole class, as specified in the mapping file of the "cmlookups" table.
Code:
<subclass name="AppointedRole" discriminator-value="AppointedRole" />
We are providing all the information that Hibenate needs to implement this association, but it would appear that this is not actually supported by Hibernate?
Is this a defect or an oversight, or are we missing something?