-->
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: Persisting multiple entities with assocations in a batch
PostPosted: Thu Apr 25, 2013 8:15 pm 
Newbie

Joined: Thu Apr 25, 2013 7:53 pm
Posts: 1
Hi,

I use Hibernate 4.1.2.Final together with the MySQL JDBC driver. I have set the hibernate.jdbc.batch_size in persistence XML to enable the batch mode. I have also added rewriteBatchedStatements=true to the MySQL JDBC driver URL. Otherwise MySQL cannot handle batches.

The problem is: The Entity Foo has the associated entities Bar with a OneToMany association.
Now the following happens: Each entity Foo is persisted one by one, then the join list Bar_Foo only for this Foo is written in a batch and the Bars only for this Foo are written in a batch. So if I have 1000 Foos these 1000 Foos are not written in a batch, but one by one. What I want is that all Foos are written in a batch, then all join lists Foo_Bar for all Foos and then all Bars for all Foos written, so 3 MySQL INSERT statements instead of 3000. Is this possible?

Thanks


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.