-->
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: delete auf Join Table ignoriert referentielle Integrität
PostPosted: Sun Sep 21, 2008 9:53 am 
Newbie

Joined: Sun Sep 21, 2008 9:49 am
Posts: 5
Hallo!

folgendes Szenario:

eine Tabelle:
Schulung
(PK: SchulungsID)
(Hash)Set Teilnehmer
...

von dieser Tabelle "erben" 2 weitere: Seminare und Workshops (beide haben als PK: SchulungsID)

desweiteren gibts eine Join-Table (Link-Tabelle) SchulungPerson (PK: SchulungsID und PersonID) über die Seminar- und Workshopteilnehmer zugeordnet werden.

Lösche ich nun mit Hibernate ein Seminar/Workshop zu dem noch Personen zugeordnet sind, wird die Referentielle Integrität "ausgehebelt". D.h. zuerst werden alle Einträge mit entsprechender SchulungsID aus der Join-Table gelöscht. Anschließend aus der Schulungstabelle und zum Schluss aus der Seminartabelle.

Ich erwarte eine ConstraintViolationException oder etwas in der Art...

Ich verwende MySql mit InnoDb. Auf Datenbankebene greift die RI, sobald versucht wird eine Schulung zu löschen, die noch Teilnehmer hat...

Muss man irgendein Attribut im Mappingfile angeben?
Code:
<hibernate-mapping>
    <class name="transfer.ToTraining" table="training">
        <id name="trainingId" type="java.lang.Integer">
            <column name="trainingId" />
            <generator class="native" />
        </id>
        <property name="from" type="date" column="von" length="10" not-null="true" />
        <property name="until" type="date" column="bis" length="10" not-null="true" />
        <property name="postcode" type="java.lang.Integer" column="postcode" not-null="true" />
        <property name="location" type="string" column="location" length="25" not-null="true" />
        <property name="street" type="string" column="street" length="45" />
        <property name="status" type="java.lang.Integer" column="status" not-null="true" />
        <set name="participants" inverse="false" table="training_person">
            <key>
                <column name="trainingId" not-null="true" />
            </key>
            <many-to-many entity-name="transfer.ToPerson">
                <column name="personId" not-null="true" />
            </many-to-many>
        </set>
        <joined-subclass name="transfer.ToSeminar" table="seminar" >
        <key column="trainingId" />
        <property name="name" type="string" column="name" length="30" not-null="true" />
        <property name="content" type="string" column="content" length="65535" not-null="true" />
        <property name="seminarcode" type="string" column="seminarcode" length="10" not-null="true" />
        <property name="price" type="java.lang.Double" column="price" precision="7" not-null="true" />
        <property name="inhouse" type="java.lang.Boolean" column="inhouse" not-null="true" />
        <property name="constancy" type="java.lang.Double" column="constancy" precision="3" scale="1" not-null="true" />
        <property name="participatorMin" type="java.lang.Integer" column="participator_min" not-null="true" />
        <property name="participatorMax" type="java.lang.Integer" column="participator_max" not-null="true" />
        </joined-subclass>
        <joined-subclass name="transfer.ToWorkshop" table="workshop">
        <key column="trainingId" />
        <many-to-one name="consultant" class="transfer.ToPerson" fetch="select">
            <column name="consultant" not-null="true" />
        </many-to-one>
        <many-to-one name="subject" class="transfer.ToSubject" fetch="select">
            <column name="subject" not-null="true" />
        </many-to-one>
        </joined-subclass>
    </class>
</hibernate-mapping>


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.