Hi,
I am getting a "java.lang.OutOfMemoryError: Java heap space" error when I call query.executeUpdate() many times within a transaction.
On my PC the following code (test code to prove the error) fails somewhere between 160000 and 170000. Is there an explanation for this? I know I can workaround this by dividing the work in multiple transactions. I am using Hibernate 3.2.6.GA.
Thanks.
Code:
int count = 0;
Query query = entityManager.createNativeQuery("insert into table_a select table_a_seq.nextval from dual");
while (count < 200000) {
query.executeUpdate();
if (++count % 100 == 0) {
session.clear();
}
if (count % 10000 == 0) {
System.out.println("Count: " + count);
}
}
When running the code with JProbe (Java Profiler) the top runtime instances are:
java.util.HashMap$Entry -> count = 2.189.880
java.util.HashMap$Entry[] -> count = 24.606
java.util.HashMap -> count = 24.606
ps. I don't get the error if I change the insert into a select and call query.getResultList() in the while loop.