Thank you very much for your answer.
This is the code resultig after your suggestion:
Code:
Transaction tx=null;
try{
tx = session.beginTransaction();
Connection con = session.connection();
Statement stmt = con.createStatement();
for (Iterator iter = dtos.iterator(); iter.hasNext();) {
IntegracaoEstabDTO dto = (IntegracaoEstabDTO) iter.next();
//stmt.execute("update estabelecimento set totalAlunos = " + dto.getTotalAlunos() + " where municipio.codigo = " + dto.getCodigoMunicipio() + " and codigoEstabelecimento = " + dto.getCodigoEstabelecimento());
stmt.addBatch("update Estabelecimento set totalAlunos = " + dto.getTotalAlunos() + " where municipio.codigo = " + dto.getCodigoMunicipio() + " and codigoEstabelecimento = " + dto.getCodigoEstabelecimento());
}
stmt.executeBatch();
session.flush();
tx.commit();
}
catch(HibernateException he){ ....
It works, executing all the querys.
The problem now is the time that every query spends running, about 0.75 seconds. Considering that there are about 7000 querys, it will take 1 hour to run. If I run this code, without get the connection from hibernate, all the process takes about 40 seconds.
Is something I'm doing wrong?
Thanks in advice.