-->
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: Hibernate starts deleting from "wrong" table
PostPosted: Thu Jun 15, 2006 8:58 am 
Newbie

Joined: Thu Jun 15, 2006 7:20 am
Posts: 2
I have a problem with deleting an object with Hibernate. The mapping is this:

Class Report
Code:
<class name="Report" table="report">

        <id name="id" type="long" unsaved-value="0">
            <column name="report_id" sql-type="integer" not-null="true"/>
            <generator class="native"/>
        </id>

        <property name="folderCreated" not-null="true" />
        <property name="draftDeadline" not-null="false" />
        <property name="finalDeadline" not-null="false" />

        <many-to-one name="treeNode" cascade="none" lazy="false" class="TreeNode" />

</class>

Class M3Item
Code:
<joined-subclass name="M3Item" extends="Item" table="item_m3">
            <key column="item_id"/>
            <property name="type" not-null="true" />
            <property name="specificType" not-null="false" />
            <set name="reports" inverse="false" cascade="all" table="item_m3_reports">
                <key column="item_id"/>
                <many-to-many unique="true" column="report_id" class="Report"/>
            </set>
            <property name="identifier"/>
            <property name="startDate"/>
            <property name="endDate"/>
            <property name="itemNumber" not-null="true"/>
            <property name="duration" not-null="true" />
            <property name="deadlineProtocol"/>
            <property name="laboratories"/>
            <property name="CRO"/>
            <property name="createFolder" not-null="true" />
</joined-subclass>



When I try to delete a Report using:

Code:
tx = getCurrentSession().beginTransaction();
getCurrentSession().delete(object);
commitTransaction(tx);


Hibernate starts by executing the following SQL:

delete from report where report_id=?

This causes a ConstraintViolation. Which isn't so strange as a row has to be removed from the join table (item_m3_reports) first. How can i make sure that the row from the join table is deleted first?


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.