views:

90

answers:

0

I have a class that is composed of 2 composite key objects and they share a column ‘SharedColumn’. This maps fine and the composite classes’s one-to-Many mappings work fine.

<class name="PAIR">
     <composite-id>
       <key-many-to-one name="first" class="Class1">
      <column name="SharedColumn"/>
      <column name="Column1" />
       </key-many-to-one>
       <key-many-to-one name="second" class="Class1" >
      <column name="SharedColumn"/>
      <column name="Column2" />
       </key-many-to-one>
     </composite-id>
    </class>

The problem is if I try to build a map that references this pair class. It doesn't matter which method I use both maps say I have an incorrect amount of columns.

<many-to-one class="PAIR">
  <column name="SharedColumn" />
  <column name="Column1" />
  <column name="Column2" />
</many-to-one>


<many-to-one class="PAIR">
      <column name="SharedColumn" />
      <column name="Column1" />
      <column name="SharedColumn" />
      <column name="Column2" />
</many-to-one>

Could anyone point me in the right direction? I would rather not add a surrogate key because this tactic has been used many times throughout the data model.