-->
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.  [ 4 posts ] 
Author Message
 Post subject: hibernate batch-updates in case of cascade to children.
PostPosted: Thu Mar 13, 2008 4:55 pm 
Newbie

Joined: Fri Aug 17, 2007 8:36 am
Posts: 3
This question is regarding performance of an application using hibernate .

If i have a parent P (with cascade save-update to children C's ) .
If we have 1000 (new/dirty) children (already referred in P) .

And if we call save on Parent P , this tries to save Parent and 1000 Children of this parent.

In this case does hibernate use batch updates ?

or

Should we explicitly use batch update implementation in our code

like :
Code:

while(hasNextChild()) {
  for(int i=0;i<30;i++) {
    session.save(c)
    session.flush();
   }
}




Thanks,

Kurt


Top
 Profile  
 
 Post subject: Re: hibernate batch-updates in case of cascade to children.
PostPosted: Thu Mar 13, 2008 5:02 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
Only if you have set hibernate.jdbc.batch_size property. In addition you should remove the flush call.



Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 5:07 pm 
Newbie

Joined: Fri Aug 17, 2007 8:36 am
Posts: 3
Did you read my post properly? .Can you just elaborate ?

Do you mean the save on Parent -> if it cascades saves on children by hibernate (is batch update implementation? ) ..


I did not get any thing out of your answer !!!!!

Thx,

Kurt


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 5:12 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
I give you more explanation. As far as I know Hibernate caches modified objects in a queue and save them when it is appropriate (if flushmode is auto). Therefore, when you have a parent and modified objects then hibernate will definitely look into batch updating if that property is set. however, something I missed from your original post was that there are new objects too. That still can work if the object's primary keys are not identity or anything for which hibernate has to go to database and come back with a value. If not, batch update still works.

Tell me if I am off the topic. I also have a feeling I have not understood your question.


Farzad-


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