When using aaa.hbm.xml file and bbb.hbm.xml file,
both has attribute 'list', and their ids are as another table's id(tablename:aaa_bbb),
this is required.
than list has attribute 'index', name : serial
but the primary key indeed in database aaa_bbb is serial and aaa's id.
would you tell me my errer ?
thank you very much
Hibernate version: 2.1.2
Mapping document:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="aaa" table="aaa">
<cache usage="read-write"/>
<id name="userID" type="long" unsaved-value="0">
<column name="USERID" not-null="true"/>
<generator class="native"/>
</id>
<list name="roles" table="aaa_bbb" lazy="true" inverse="true" outer-join="auto" >
<key column="USERID"/>
<index type="int">
<column name="serial"/>
</index>
<many-to-many class="bbb" column="ROLEID"/>
</list>
</class>
</hibernate-mapping>
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="bbb" table="bbb">
<cache usage="read-write"/>
<id name="roleID" type="long" unsaved-value="0">
<column name="ROLEID" not-null="true"/>
<generator class="native"/>
</id>
<list name="users" table="aaa_bbb" lazy="true" outer-join="auto">
<key column="ROLEID"/>
<index type="int">
<column name="serial"/>
</index>
<many-to-many class="aaa" column="USERID"/>
</list>
</class>
</hibernate-mapping>
[/code]