-->
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 (jpa - ejb3) bulk loading issues
PostPosted: Tue Jul 05, 2011 11:01 am 
Newbie

Joined: Tue Jul 05, 2011 10:49 am
Posts: 1
I am reading in a large xml file and butting it into xml beans then comiting each record into the database. Without the hibernate database code it reads the 200MB xml file and puts them into xml beans in 30-60 seconds. The problem comes when we try to use hibernate to add to the databsae - its REALLY SLOW. We need transactions around each record as any error has to limit what does not get added to the database. But the transaction part is not only the slow part, there are long pauses after persist is called, and before transaction is comited as well, I added log statements for new java.util.Date to see how long each statement was taking. Sometimes its 60+ seconds on persist. JDBC on the other hand and sql developer are really fast accessing this database. I open only one entity manager and entity manager factory at the start and close it at the end , pass it into method which creates transaction and persists the result then closes the transaction

here is persistence.xml values
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version = "2.0" xmlns = "http://java.sun.com/xml/ns/persistence" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name = "persistenceUnit" transaction-type = "RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <class>package.real.names.left.out.class2</class>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
            <property name = "hibernate.dialect" value = "org.hibernate.dialect.Oracle10gDialect"/>
            <property name = "hibernate.connection.driver_class" value = "oracle.jdbc.driver.OracleDriver"/>
            <property name = "hibernate.show_sql" value="false" />
            <property name = "hibernate.format_sql" value="false" />           
            <property name = "hibernate.connection.username" value = "test"/>
            <property name = "hibernate.connection.password" value = "test"/>
            <property name = "hibernate.connection.url" value = "jdbc:oracle:thin:@127.0.0.1:1521:test"/>
            <property name = "hibernate.jdbc.batch_size" value = "0"/>
            <property name = "hibernate.max_fetch_depth" value = "99"/>
            <property name = "hibernate.connection.provider_class" value = "org.hibernate.connection.C3P0ConnectionProvider" />
            <property name = "hibernate.c3p0.max_size" value="1" />
            <property name = "hibernate.c3p0.min_size" value="1" />
            <property name = "hibernate.c3p0.acquire_increment" value="2" />
            <property name = "hibernate.c3p0.idle_test_period" value="300" />
            <property name = "hibernate.c3p0.max_statements" value="0" />
            <property name = "hibernate.c3p0.timeout" value="100" />                 
        </properties>
    </persistence-unit> 
</persistence>



Top
 Profile  
 
 Post subject: Re: Hibernate (jpa - ejb3) bulk loading issues
PostPosted: Tue Jul 05, 2011 11:43 am 
Beginner
Beginner

Joined: Fri Jul 20, 2007 10:38 am
Posts: 49
After doing the commit, the persisted object is level 1 cached. So that cache get's full and something needs to go (the oldest object/s for instance). Because you are batch processing, that limit is reached quickly etc. Anyway, perhaps it's possible to issue a flush on the session after the commit?


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.