I am working with a legacy database (that I did not design, and unfortunately cannot change) that uses composite-keys for its code tables.
In tables that reference the code table, they typically have paired a "LanguageCode" value (eg. "EN") with some other kind of code value. I have built a composite key class for each code table, and NHibernate is handling the relationship without problem.
Unfortunately, it some cases they have created MULTIPLE composite foreign keys to different code tables, but all of them share the concept of the LanguageCode column as part of the composite key.
Below are my settings for the hbm.xml file where I have two of these composite keys. NHibernate is rejecting this when I attempt to save the row, because it is constructing an INSERT statement that includes the LanguageCode twice (once for each many-to-one tag).
Code:
<many-to-one name="PaymentMethod" class="PaymentMethod" fetch="select">
<column name="PaymentMethodCode" length="10" not-null="true" />
<column name="LanguageCode" length="3" not-null="true" />
</many-to-one>
<many-to-one name="PayOnAmount" class="PayOnAmount" fetch="select">
<column name="PayOnAmountCode" length="10" not-null="true" />
<column name="LanguageCode" length="3" not-null="true" />
</many-to-one>
For now, I am not using the composite foreign key for classes where there are multiple composite foreign keys expected.
Is there any way to instruct NHibernate to not include LanguageCode mutiple times in its INSERT statement?
Thanks,
David