Hi All. I'm having a problem with my app in a save section. I'm using Spring 3.0.0 and Hibernate 3.2.5
I need to save a lot of things in a for, but when I save 3 or 4 objects the appplication sleeps and I don't know how or what is the problem. If I'm debugging de app in that moment the variables disappear from the section of variables in the IDE, and the app sleeps. I have tried to capture the exceptions, but there are no exceptions to capture
This is the code of the save method. It's the same for all the Classes and all daos extend this Generic DAO
Code:
@Transactional
public void guardar(T objeto) throws DataAccessException {
try {
getHibernateTemplate().saveOrUpdate(objeto);
} catch (Exception e) {
System.err.println(e.getCause());
e.printStackTrace();
System.err.println(e.getMessage());
}
}
and this is my code in the application
Code:
@Override
@Transactional
public void generarFixture(Categoria c) throws MensajeDeExcepcion {
if (fSrv.getFechasDeCategoria(c.getIdCategoria()) != null) {
List<Equipo> equipos = this.getEquipos(c);
Random r = new Random(System.currentTimeMillis());
Collections.shuffle(equipos, r);
List<Equipo> equiposLocales = new ArrayList<Equipo>(equipos);
List<Equipo> equiposVisitantes = new ArrayList<Equipo>(equipos);
final int CANT_EQUIPOS = equiposLocales.size();
final Equipo ultimo = equiposLocales.remove(CANT_EQUIPOS - 1);
equiposVisitantes.remove(CANT_EQUIPOS - 1);
for (int fila = 0; fila < CANT_EQUIPOS - 1; fila++) {
Fecha f = new Fecha();
f.setCategoria(c);
f.setNumeroFecha(fila + 1);
f.setPartidos(new ArrayList<Partido>());
Estado estado = eSrv.getEstadoByNombreAndObjeto("Activo", "Partido");
logger.info("*****");
logger.info("Fecha " + (fila + 1));
//SAVE FECHA
fSrv.guardarFecha(f);
for (int col = 0; col < CANT_EQUIPOS / 2; col++) {
Equipo eqVisitante;
Equipo eqLocal;
if (col == 0) {
if (fila % 2 == 0) {
eqVisitante = equiposLocales.remove(0);
eqLocal = ultimo;
equiposLocales.add(eqVisitante);
} else {
eqLocal = equiposLocales.remove(0);
eqVisitante = ultimo;
equiposLocales.add(eqLocal);
}
} else {
eqLocal = equiposLocales.remove(0);
eqVisitante = equiposVisitantes.remove(equiposVisitantes.size() - 1);
equiposLocales.add(eqLocal);
equiposVisitantes.add(0, eqVisitante);
}
Partido p = new Partido();
p.setFecha(f);
p.setEquipoLocal(eqLocal);
p.setEquipoVisitante(eqVisitante);
p.setCategoria(c);
p.setEstado(estado);
logger.info("Partido " + (col + 1) + " " + eqLocal.getNombre() + " vs "
+ eqVisitante.getNombre());
//SAVE PARTIDO
pSrv.guardar(p);
}
}
pSrv.guardar(todosLosPartidos);
} else {
throw new MensajeDeExcepcion("La categoria ya tiene fechas");
}
}
in the moment to save the object, the HibernateTemplate has this values:
Quote:
hibernateTemplate HibernateTemplate (id=113)
allowCreate true
alwaysUseNewSession false
beanFactory null
cacheQueries false
checkWriteOperations true
defaultJdbcExceptionTranslator null
entityInterceptor null
exposeNativeSession false
fetchSize 0
filterNames null
flushMode 1
jdbcExceptionTranslator null
logger Log4JLogger (id=121)
maxResults 0
queryCacheRegion null
sessionFactory SessionFactoryImpl (id=122)
Anyone has the same problem?