-->
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: hibernate not batching even though order_insert=true
PostPosted: Wed Jun 30, 2010 4:45 pm 
Newbie

Joined: Wed Jun 30, 2010 3:21 pm
Posts: 2
I am using Hibernate 3.5.0-Final with PostGres SQL 8.4.2, JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.4 JDBC3

I am doing something similar to below mentioned code for batching and have set the configurations as

hibernate.order_inserts=true
hibernate.order_updates=true
hibernate.jdbc.batch_size=5
hibernate.jdbc.batch_versioned_data=true

public void doBatch() {

for ( int i=0; i<100000; i++ ) {
Customer customer = new Customer(.....);
session.save(customer);
if ( i % 5 == 0 )
session.flush();
}

The customer entity is associated with another entity say 'Cart'.
So, a single save(customer) generate 2 insert statements.

insert into Customer values (...)
insert into Cart values(...)

Even though the ordering of inserts is enabled, for some reason hibernate is not ordering the inserts and batching them.

the log shows something like:

Executing batch size: 1
2010-06-30 10:35:48,378 [qtp53489605-13] [DEBUG]: insert into Customer(?, ?, ?)
2010-06-30 10:35:48,378 [qtp53489605-13] [DEBUG]: insert into Cart(?, ?)
.
.
Executing batch size: 1
2010-06-30 10:35:48,378 [qtp53489605-13] [DEBUG]: insert into Customer(?, ?, ?)
2010-06-30 10:35:48,378 [qtp53489605-13] [DEBUG]: insert into Cart(?, ?)
.
.
Any help would be greatly appreciated

Thanks,
Vivake


Top
 Profile  
 
 Post subject: Re: hibernate not batching even though order_insert=true
PostPosted: Fri Jul 02, 2010 10:06 am 
Newbie

Joined: Wed Jun 30, 2010 3:21 pm
Posts: 2
I found the answer,

Hibernate does not batch Joined-SubClass entities. This is the comment from the hibernate source code AbstractEntityPersister.java

// we can't batch joined inserts, *especially* not if it is an identity insert;
// nor can we batch statements where the expectation is based on an output param

Also see the link viewtopic.php?f=1&t=996815


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.