Camnbios en PatrocinadorDaoJPA y ProyectoDaoJPA

This commit is contained in:
Isidoro Nevares Martín 2026-01-29 10:52:50 +01:00
parent 12b301d8fb
commit de0d013937
2 changed files with 29 additions and 28 deletions

View File

@ -48,15 +48,16 @@ public class PatrocinadorDaoJPA implements IPatrocinadorDAO {
@Override @Override
public void actualizarEntidad(Patrocinador entidad) throws ProyectosIESException { public void actualizarEntidad(Patrocinador entidad) throws ProyectosIESException {
Transaction transaccion = null; EntityManager gestorEntidades = null;
Session sesion = null; EntityTransaction transaccion = null;
try { try {
sesion = GestorSesionesHibernate.getSession(); gestorEntidades = GestorEntityManagerJPA.getEntityManager();
transaccion = sesion.beginTransaction(); transaccion = gestorEntidades.getTransaction();
transaccion.begin();
if(sesion.contains(entidad)) if (gestorEntidades.contains(entidad))
sesion.merge(entidad); gestorEntidades.merge(entidad);
transaccion.commit(); transaccion.commit();
} catch (Exception e) { } catch (Exception e) {
@ -65,8 +66,8 @@ public class PatrocinadorDaoJPA implements IPatrocinadorDAO {
} }
throw new ProyectosIESException(e, this.getClass(), ProyectosIESException.ERROR_ACTUALIZACION); throw new ProyectosIESException(e, this.getClass(), ProyectosIESException.ERROR_ACTUALIZACION);
} finally { } finally {
if (sesion != null) { if (gestorEntidades != null) {
sesion.close(); gestorEntidades.close();
} }
} }
} }
@ -106,5 +107,4 @@ public class PatrocinadorDaoJPA implements IPatrocinadorDAO {
} }
} }

View File

@ -71,15 +71,16 @@ public class ProyectoDaoJPA implements IProyectoDAO {
@Override @Override
public void actualizarEntidad(Proyecto entidad) throws ProyectosIESException { public void actualizarEntidad(Proyecto entidad) throws ProyectosIESException {
Transaction transaccion = null; EntityManager gestorEntidades= null;
Session sesion = null; EntityTransaction transaccion = null;
try { try {
sesion = GestorSesionesHibernate.getSession(); gestorEntidades = GestorEntityManagerJPA.getEntityManager();
transaccion = sesion.beginTransaction(); transaccion = gestorEntidades.getTransaction();
transaccion .begin();
if (sesion.contains(entidad)) if (gestorEntidades.contains(entidad))
sesion.merge(entidad); gestorEntidades.merge(entidad);
transaccion.commit(); transaccion.commit();
} catch (Exception e) { } catch (Exception e) {
@ -88,8 +89,8 @@ public class ProyectoDaoJPA implements IProyectoDAO {
} }
throw new ProyectosIESException(e, this.getClass(), ProyectosIESException.ERROR_ACTUALIZACION); throw new ProyectosIESException(e, this.getClass(), ProyectosIESException.ERROR_ACTUALIZACION);
} finally { } finally {
if (sesion != null) { if (gestorEntidades != null) {
sesion.close(); gestorEntidades.close();
} }
} }
} }