I tried just adding the column to the composite-element. See below,
the "PROJECT_ID" column inside the <composite-element> tag inside
the <idbag> tag.
Unfortunately, Hibernate doesn't like the fact that the PROJECT_ID
column is now mapped twice, once as the collection-id, and once as
an attribute. The exception is
org.hibernate.MappingException: Repeated column in mapping for collection: com.wholefoods.ittoolkit.ws.admin.Team.projects column: PROJECT_ID
I tried adding a 'name=' attribute to the <collection-id> but that is
not allowed by the DTD.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.wholefoods.ittoolkit.ws.admin">
<class name="Team" table="CR_TEAM">
<id name="id" column="TEAM_ID">
<generator class="sequence">
<param name="sequence">CR_TEAM_ID</param>
</generator>
</id>
<property name="version" column="VERSION"/>
<property name="name" column="NAME"/>
<property name="email" column="EMAIL"/>
<property name="remedyGroupId" column="RMDY_GROUP_ID"/>
<set name="members" table="CR_TEAM_MEMBER">
<key column="TEAM_ID"/>
<composite-element class="TeamMember">
<property name="name" column="NAME" not-null="true"/>
<property name="email" column="EMAIL" not-null="true"/>
<property name="userId" column="USER_ID" not-null="true"/>
<property name="roleId" column="ROLE_ID" not-null="true"/>
</composite-element>
</set>
<idbag name="projects" table="CR_PROJECT" order-by="NAME asc">
<collection-id type="long" column="PROJECT_ID">
<generator class="sequence">
<param name="sequence">CR_PROJECT_ID</param>
</generator>
</collection-id>
<key column="TEAM_ID"/>
<composite-element class="TeamProject">
<property name="id" column="PROJECT_ID"/>
<property name="name" column="NAME" not-null="true"/>
</composite-element>
</idbag>
</class>
</hibernate-mapping>