-->
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.  [ 7 posts ] 
Author Message
 Post subject: cascade delete performance
PostPosted: Mon Apr 30, 2007 4:27 am 
Newbie

Joined: Thu Mar 01, 2007 4:13 am
Posts: 4
Hi Guys,

I have an application that has a parent table and many child and grandchild tables. They are all related by keys.

When I clear all the contents of a collection ( which is the data of one child table and its associated children ) each row in the table, and child table is deleted individually, and this takes an absolute age as there can be 50-150,000 rows of data.



public boolean process_price(HSSFRow row, DATAImpl data, boolean clear, Hashtable messages, String currentSchema, Hashtable columnIndexes) throws Exception {
try {
// grab the list
List list = data.getPRICE();
if (clear) {
list.clear();
}
PRICE object = (PRICE) this.objectFactory.createPRICE();


Is there some clever way to clear the contents of a collection without doing individual deletes on all rows and then all related rows in child tables ?

e.g. one delete statement for each table, or a special cascade delete.

Thanks

Paul.


Top
 Profile  
 
 Post subject: Re: cascade delete performance
PostPosted: Mon Apr 30, 2007 4:53 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
paulhussein wrote:
Is there some clever way to clear the contents of a collection without doing individual deletes on all rows and then all related rows in child tables ?

Not in Hibernate, I don't think no.

paulhussein wrote:
e.g. one delete statement for each table, or a special cascade delete.

Maybe write a JDBC method to do that? >_>

_________________
Everytime you get an answer to your question without giving credit; god kills a kitten. :(


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 30, 2007 5:51 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Search the documentation, it's called "one shot delete for collections".

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 30, 2007 5:51 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
And of course it only works conceptually and in practice for collections of value types (strings, dates, components), not for a parent/child entity relationship.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 30, 2007 5:56 am 
Newbie

Joined: Thu Apr 19, 2007 1:46 am
Posts: 10
Hi ,
The way out I can think of is like
Remove all the constraints at the DB level.At Hibernate level you can remove the cascade constraints.
The way out is manage them at the application level.

Ans you can have a scheduled script that removes the non refrenced rows in the child table .


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 01, 2007 10:03 am 
Newbie

Joined: Thu Mar 01, 2007 4:13 am
Posts: 4
Thanks guys, I will try these suggestions out.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 11, 2007 3:08 pm 
Newbie

Joined: Mon Apr 16, 2007 2:05 pm
Posts: 5
I was looking a month for a solution for this problem. Search did not work because the terms are too usual.

_________________
search engine placement


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.