-->
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: Hibernate and Batch
PostPosted: Fri Oct 02, 2009 4:37 am 
Newbie

Joined: Fri Oct 02, 2009 4:25 am
Posts: 1
Hi,

I currently have to insert 300 000 users from an xml file on a database.
I read my xml file with SAX and insert 3 differents objects in my oracle database for each users.
But, i'm facing something strange. Every n inserts there is a sleep for 20 / 30 seconds. i can't find why.

Here is my parameter for the hiberante.cfg.xml :
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:XXXX</property>
<property name="hibernate.connection.username">XXXX</property>
<property name="hibernate.connection.password">XXXX</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<property name="default_schema">XXXX</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>

<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="c3p0.minPoolSize">2</property>
<property name="c3p0.maxPoolSize">50</property>
<property name="c3p0.timeout">300</property>
<property name="c3p0.max_statement">5</property>
<property name="c3p0.idle_test_period">150</property>
<property name="c3p0.max_size">100</property>

<mapping resource="xxx/xxx/xxx.hbm.xml" />
....

For each create i have this code :
Session oSession = null;
Transaction tx = null;
try {
oSession = HibernateUtil.getSessionFactory().openSession() ;
tx = oSession.beginTransaction();
oSession.save(object);
oSession.flush() ;
oSession.clear() ;
tx.commit();
} catch (Exception ex) {
if (tx != null) {
tx.rollback();
}
Throws ex ;
} finally {
if (oSession != null) {
oSession.flush();
oSession.close();
}
}

Thanks in advance for your help.
Regards,

HadanMarv


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.