OK so i have 3 tables...
PRODUCT_GROUP
PRODUCT_SUBTYPE
and the many to many table...
PRODUCT_GROUP_SUBTYPE
The last table initally had 2 columns just the ids of the GROUP and SUBTYPE tables. This seemed to work perfectly well if i wanted to use sets, but didn't work at all if i wanted to use lists, as a list requires a list-index or index. WHY???
We want to use lists in our code not sets, so to get around this problem I added another column to the PRODUCT_GROUP_SUBTYPE table called PRODUCT_GROUP_SUBTYPE_ID and it just has the values 1..n (i.e. first row it's 1, 2nd row it's 2, nth row it's n)
I set the list index to this column, and all of a sudden it works....Why do I need this column???
here's the mapping...
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.hidden.value.ProductGroupValue" table="product_group">
<id name="productGroupId" column="PRODUCT_GROUP_ID" unsaved-value="0"/>
<property name="description" column="DESCRIPTION"/>
<property name="roleId" column="ROLE"/>
<list name="productSubTypes" table="product_group_subtype">
<key column="product_group_id"/>
<list-index column="product_group_subtype_id"/>
<many-to-many class="com.hidden.value.ProductSubTypeValue" column="product_subtype_id"/>
</list>
</class>
</hibernate-mapping>
It all works ok now, but just puzzled on why i should need to add the extra column??????
cheers
Andy.