I have three tables in the database:
Code:
order (id,...)
shape(id, ...)
order_has_shape(order_id, shape_id, value)
On the 'order' side I created a mapping of the collection of shapes as follows:
Code:
<class name="pl.hefajstos.core.model.Order" table="`order`">
...
<map name="shapes" table="order_has_shape">
<key column="order_id"/>
<map-key column="shape_id" type="long"/>
<composite-element class="pl.hefajstos.core.model.OrderedShape">
<property name="amount" not-null="true"/>
<many-to-one name="shape" class="pl.hefajstos.core.model.Shape" column="shape_id"/>
</composite-element>
</map>
</class>
Unfortunately Hibernate doesn't like this telling me:
Code:
org.hibernate.MappingException: Repeated column in mapping for collection: pl.hefajstos.core.model.Order.shapes column: shape_id
What I want is having (on the Order side) the collection of shapes put into a map, key of which would be the values from shape_id column.