Wow, that is ugly. Repost of code:
Code:
<hibernate-mapping>
<class name="SolutionComponent" table="solution_component">
<id name="sku" column="sku" />
….
<!-- A solution component can be have lists of other solution components
(alternative,linked) managed by the sub_component_list table
distinguished by the sub_list_type column -->
<set name="alternateComponentList" table="sub_component_list"
where="sub_list_type = 1" lazy="false">
<key column="solution_component_sku" />
<many-to-many column="sub_component_sku"
class="SolutionComponent"/>
</set>
<set name="linkedComponentList" table="sub_component_list"
where="sub_list_type = 2" lazy="false">
<key column="solution_component_sku" />
<many-to-many column="sub_component_sku"
class="SolutionComponent"/>
</set>
</class>