Okay, I know that the <key> and <index> can not both be the same column and you can't map a clumn twice to two attributes, but, dumb question of the day, why can't I use the ID of a many-to-many as the index of the List that holds them?
My tables are like so:
Code:
user_role { role_id int, role_description varchar }
role_functionality_xref { role_id int, functionality_id int }
functionality { functionality_id int, description varchar }
And my incorrect mapping attempt is:
Code:
<class name="package.UserRole" table="user_role" mutable="false">
<id name="ID" type="integer" column="role_id">
<generator class="net.sf.hibernate.id.IdentityGenerator"/>
</id>
<property name="description" column="description" type="string" not-null="true"/>
<list name="functions" lazy="true" table="role_functionality" cascade="none">
<key column="role_id"/>
<index column="functionality_id" type="integer"/>
<many-to-many class="package.Functionality" column="functionality_id"/>
</list>
</class>
<!-- Functionality -->
<class name="package.Functionality" table="functionality" mutable="false">
<id name="ID" type="integer" column="functionality_id">
<generator class="net.sf.hibernate.id.IdentityGenerator"/>
</id>
<property name="description" column="description" type="string" not-null="true"/>
</class>
I just want a List with NULL values where there are no associated records.
What would be the proper way to accomplish this? I don't really want an extra column with duplicate values of the ID.
If I take the column attribute out of the many-to-many tag I get a stack overflow with no messages when I try to run (Hibernate starts, I just can't login to my app because the first request involves the mapping in question which generates the stack overflow).