-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problems with orphan deleting
PostPosted: Thu Sep 13, 2007 10:38 am 
Newbie

Joined: Thu Sep 13, 2007 10:15 am
Posts: 1
Hello dear community.

I have a problem with a deleting behavior.

I have a class Order and OrderDetails

in Order class mapping:

Code:
<set name="ordersDetails" inverse="true" fetch="join" cascade="all-delete-orphan" >
         <key column="id_order" not-null="true" />
         <one-to-many class="OrderDetail" />
      </set>



in OrderDetail class mapping
Code:
<many-to-one name="order" class="Order" lazy="false" outer-join="true" cascade="none">
         <column name="id_order" not-null="true" />
      </many-to-one>


I have one Order and 4 OrderDetails associated with it.
when i call
Code:
session.selete(order)

The questions are:
1. Hibernate deletes only one OrderDetail and tries to delete order, but exception throws due to foreign key constraint. But if i remove fetch="join" from Order class mapping hibernate deletes all orderdetails and order - that a right behavior. What influence has
fetch="join" on cascade deletion? and why a cannot use this two mapping options together?
2. when i remove fetch="join" everything is OK, but why hibernate deletes each order detail in separate sql statement like this?
Code:
delete
        from
            sap.ordersdetails
        where
            id_detail=?
            and version=?

the better way is to delete with one delete statement:
Code:
delete
        from
            sap.ordersdetails
        where
            id_order=?
            and version=?

Can i tune hibernate like this


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 16, 2007 3:18 pm 
Beginner
Beginner

Joined: Tue Aug 16, 2005 3:44 pm
Posts: 33
I guess this is not an answer to your question, but it is in a way related :)

You might try to set the constraints defered, see http://infolab.stanford.edu/~ullman/fcdb/oracle/or-triggers.html#deferring%20constraint%20checking so they are not checked before all of the transaction is commited.


-kaj :)


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

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.