openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "C N Davies" <...@cndavies.com>
Subject RE: setting autocommit to false
Date Tue, 23 Nov 2010 09:38:19 GMT
I had a similar issue some time ago and ended up fixing it like this:

	private void persist(DataLoad ld, int count) {
		es.merge(ld);
		if (count>maxBatchSize){
			es.commitTx();
			es.clear();
		}
	}

Before I started doing it this way I was getting stack overflows even though
I had a 1024 stack.  Typically the issue was occuring if I was processing
more than about 100 records so I just batch it and commit and clear every x
records.

Hth

Chris



-----Original Message-----
From: csff [mailto:christoph.seip@first-financial.biz] 
Sent: Tuesday, 23 November 2010 7:40 PM
To: users@openjpa.apache.org
Subject: setting autocommit to false


Hi together,

i'm using openjpa 2.0.1 and for connection pooling dbcp 1.4 in a non j2ee -
environment. 

My batch-application has to do many single selects by using the
entityManager method find. 
For example : 

em.getTransaction().begin();
...
for (int i = 1; i <= 200000; ++i) { 
    MitteilungsauftragEKAPK pka = new MitteilungsauftragEKAPK(); 
    pka.setStapelNr(stapel.getStapelNr()); 
    pka.setAuftragsNr(i); 
    MitteilungsauftragEKA auftrag = em.find(MitteilungsauftragEKA.class,
pka);
}
...
em.getTransaction().commit(); 

In this case it seems, that openjpa does a (auto)commit after ever single
select which results in a bad performace. When I modify another object
within the started transaction and call entityManager.flush() ist works fine
and the performance ist much better. In this case openjpa only does a commit
at the end of the started transaction. 

My question is : how can ich force openjpa to do no autocommit. 

I've tried to set the Connection-property DefaultAutoCommit to false in the
persistence.xml file without any success:

<property name="openjpa.ConnectionDriverName"
value="org.apache.commons.dbcp.BasicDataSource"/>
<property name="openjpa.ConnectionProperties" 
value="DriverClassName=com.ibm.db2.jcc.DB2Driver,
Url=zzz,
Username=xxx,
Password=yyy,
InitialSize=1,
MaxActive=5,
MaxIdle=-1,
DefaultAutoCommit=false,
PoolPreparedStatements=true,
ConnectionRetainMode=always,
MaxOpenPreparedStatements=50" /> 
 
Thanks
csff
--
View this message in context:
http://openjpa.208410.n2.nabble.com/setting-autocommit-to-false-tp5765839p57
65839.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message