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>