hello,
I am not clear on how to map this bidirectinal many - to many relationship
We have 3 tables
1. Person (id, name, adddress, age etc)
2. Category( catName, catCode etc)
3. Catmember(id,fk:id, fk:catCode, lastUpdateDate, Start Date etc)
SO catmember is like ajoin table but with extra fields.
the mapping we have is as follows
in
Person.hbm.xml
Code:
<set name ="categories" inverse="true" cascade="all" table="CatMember">
<key column="ID" not-null ="true"/>
<one-to-many class="CatMember"/>
</set>
in Category.hbm.xml
Code:
<set name ="members" inverse="true" cascade="all" table="CatMember">
<key column="catCode" not-null ="true"/>
<one-to-many class="Person"/>
</set>
the entire CatMember.hbm.xml
Code:
<hibernate-mapping package="com.myapp.domain">
<class name="CatMember" table="CatMember">
<id name="id" column="CM_ID" type="long" access="field">
<generator class="increment" />
</id>
<many-to-one name="member" column="ID"/>
<many-to-one name="category" column="CatCODE"/>
<property name="startDate" column="CM_START_DATE" type="date"/>
<property name="expireDate" column="CM_EXPIRE_DATE" type="date"/>
<property name="lastUpdateDate" column="CM_LAST_UPDATE_DATE" type="date"/>
</class>
</hibernate-mapping>
When we try to remove a category from a person it doesnot remove it from the catMember set. I know it has something to do with cascade attribute in the set property.
Any help would be greatly appreciated.
Thanks
Somesh
Code:
Code: