You probably got this sorted already, as the question was posted a few
days ago, but....
If you're just doing a find you don't need to use
em.getTransaction().begin();
em.getTransaction().commit();
so you code can just become:
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);
}
Not sure if that answers your question or not....
On 23/11/10 08:39, csff wrote:
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