-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem mit foreign-key / cascade delete bei many-to-many
PostPosted: Thu Mar 13, 2008 1:18 pm 
Newbie

Joined: Thu Mar 13, 2008 12:59 pm
Posts: 2
Hallo,

ich habe zwei Klassen mit unidirektionaler n:m Beziehung in extra Tabelle:

<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>

Beim generieren von DDL für Oracle werden folgende Constraints erzeugt:

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;

Ich brauche beim zweiten Constraint auch ein 'on delete cascade', habe aber keinen Weg gefunden, Hibernate dazu zu bewegen. Bei many-to-many kann ich zwar foreign-key="FKOrgPaketPaket" angeben, aber nicht on-delete="cascade".
Das selbe Problem habe ich bei one-to-one, auch hier wird kein 'on delete cascade' erzeugt.

Gibts noch einen anderen Weg den ich übersehen habe?

Gruß,
Bernd


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.