Im working on a legacy database, that cant be changed.
I have a table (Table1) with a many-to-one relationship with another table (Table2) which has a composite key.
If everything was strait forward the mapping for table1 could look like this:
<class name="Table1" table="Table1">
<id name="Id" column="I_ID"></id>
<many-to-one name="Table2" class="Table2">
<column name="I_TABLE2_ID1"></column>
<column name="I_TABLE2_ID2"></column>
</many-to-one>
</class>
My problem is that I dont have no I_TABLE2_ID2 column in Table1.
So I would like to use a default value instead. Is there any way to accomplish this in the mapping file?
EDIT1:
The following mapping seem to work:
<class name="Table1" table="Table1">
<id name="Id" column="I_ID"></id>
<property name="Table2Id1" column="I_TABLE2_ID1"></property>
<bag name="Table2" where="I_ID2 = 12">
<key column="I_ID1" property-ref="Table2Id1"></key>
<one-to-many class="Table2"/>
</bag>
</class>
Also I had to change the type of the Table2 property to an IList, but guess I could use a private property to make the entity look better...