Is it possible to have a “map” mapping for a many-to-many relationship in which a key maps to multiple values? That is, the value type would itself be a collection. It says in the documentation that “collections may not contain other collections” which seems to preclude this. Even so, might there be some way I could map a ternary association to such an interface (without creating additional database tables)?
The solution I am using for the time-being, is to create a new entity which maps to what would otherwise be the association table. The main entity then contains a one-to-many set mapping to the new entity:
Code:
<joined-subclass name="ParentClass">
…
<set name="BinaryRelations" inverse="true" cascade="all-delete-orphan">
<key column="ParentID"/>
<one-to-many class="BinaryRelation"/>
</set>
</joined-subclass>
<class name="BinaryRelation">
<id name="ID"><generator class="native"/></id>
<many-to-one name="Parent" column="ParentID" class="ParentClass" not-null="true"/>
<many-to-one name="Left" not-null="true"/>
<many-to-one name="Right" not-null="true"/>
</class>