Hibernate version: 3.2.6.ga
Hi,
I have two classes with an unidirectional many-to-many relation, the relation is stored in a separate table:
Code:
<hibernate-mapping>
<class name="Org" table="ORG">
<id name="id" type="long">
<column name="ID" />
<generator class="native" />
</id>
<property name="orgkey" type="string">
<column name="ORGKEY" length="20" />
</property>
<property name="name" type="string">
<column name="NAME" length="50" />
</property>
<set name="pakete" table="ORGPAKET" >
<key foreign-key="FKOrgPaketOrg" on-delete="cascade">
<column name="ORGID" scale="0" index="IDXOrgPaketOrg" />
</key>
<many-to-many foreign-key="FKOrgPaketPaket" class="Paket">
<column name="PAKETID" scale="0" index="IDXOrgPaketPaket" />
</many-to-many>
</set>
</class>
</hibernate-mapping>
the generated oracle ddl for the relations table's fk constraints :
Code:
alter table HIBERNATE.ORGPAKET
add constraint FKOrgPaketOrg
foreign key (ORGID)
references HIBERNATE.ORG
on delete cascade;
alter table HIBERNATE.ORGPAKET
add constraint FKOrgPaketPaket
foreign key (PAKETID)
references HIBERNATE.PAKET;
the first constraint contains 'on delete cascade'. When a record in the first table is deleted, all relations are deleted. I also need a 'on delete cascade' in the second constraint, but I did not find a way to define one?
Does anybody have a solution for this?
thanks,
Bernd