I have the following method that inserts a large batch of records every few seconds. After some time of running I get errors like the following:
ERROR: C
Transaction tx = session.beginTransaction();
try {
for (int i = 0; i < mesages.size(); i++) {
Message message = messages.get(i);
session.save(message);
if (i % 75 == 0) {
// flush a batch of inserts and release memory:
session.flush();
session.clear();
}
}
tx.commit();
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
tx.rollBack();
}finally{
session.close();
}
}