Hi,
I have a problem in setting the many to many relationship with composite keys. I have two tables namely "PARTY" and "GROUP". These tables have a relation of many to many. So there is an association table "GROUP_PARTY".
In "PARTY" table (partyId and versionId) -> composite key In "GROUP" table (GroupId and VersionId) -> composite key In "GROUP_PARTY" table (partyId,GroupId,VersionId) -> composite key
In group.hbm.xml file i have set the many to many as :
<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="Group" table="SHAPE_GROUP"> <composite-id name="groupPK" class="GroupPK"> <key-property name="groupId" column="GROUP_ID"/> <key-property name="versionId" column="VERSION_ID"/> </composite-id> <property name="groupName"> <column name="GROUP_NAME" /> </property> <property name="createdBy"> <column name="CREATED_BY" /> </property> <property name="createdDate"> <column name="CREATED_DATE" /> </property> <set name="parties" table="GROUP_PARTY"> <key> <column name="GROUP_ID"/> <column name="VERSION_ID"/> </key> <many-to-many class="Party"> <column name="PARTY_ID"></column> <column name="VERSION_ID"></column> </many-to-many> </set> </class> </hibernate-mapping>
But it didnt work.
Can you please suggest me a workaround for this problem.
Thanks and Regards kavitha
|