Camnbios en PatrocinadorDaoJPA y ProyectoDaoJPA
This commit is contained in:
parent
de0d013937
commit
44131f2b65
@ -1,12 +1,8 @@
|
||||
package es.palomafp.aadd.inm.dao.jpa;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
|
||||
import es.palomafp.aadd.inm.dao.IPatrocinadorDAO;
|
||||
import es.palomafp.aadd.inm.excepcion.ProyectosIESException;
|
||||
import es.palomafp.aadd.inm.gestor.GestorEntityManagerJPA;
|
||||
import es.palomafp.aadd.inm.gestor.GestorSesionesHibernate;
|
||||
import es.palomafp.aadd.inm.vo.Patrocinador;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.EntityTransaction;
|
||||
|
||||
@ -1,12 +1,8 @@
|
||||
package es.palomafp.aadd.inm.dao.jpa;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
|
||||
import es.palomafp.aadd.inm.dao.IProyectoDAO;
|
||||
import es.palomafp.aadd.inm.excepcion.ProyectosIESException;
|
||||
import es.palomafp.aadd.inm.gestor.GestorEntityManagerJPA;
|
||||
import es.palomafp.aadd.inm.gestor.GestorSesionesHibernate;
|
||||
import es.palomafp.aadd.inm.vo.Proyecto;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.EntityTransaction;
|
||||
@ -22,15 +18,15 @@ import jakarta.persistence.TypedQuery;
|
||||
*/
|
||||
public class ProyectoDaoJPA implements IProyectoDAO {
|
||||
@Override
|
||||
public void crearEntidad(Proyecto entidad) throws ProyectosIESException{
|
||||
EntityManager gestorEntidades= null;
|
||||
public void crearEntidad(Proyecto entidad) throws ProyectosIESException {
|
||||
EntityManager gestorEntidades = null;
|
||||
EntityTransaction transaccion = null;
|
||||
|
||||
|
||||
try {
|
||||
gestorEntidades = GestorEntityManagerJPA.getEntityManager();
|
||||
transaccion = gestorEntidades.getTransaction();
|
||||
transaccion .begin();
|
||||
|
||||
transaccion.begin();
|
||||
|
||||
gestorEntidades.persist(entidad);
|
||||
|
||||
transaccion.commit();
|
||||
@ -43,7 +39,7 @@ public class ProyectoDaoJPA implements IProyectoDAO {
|
||||
if (gestorEntidades != null) {
|
||||
gestorEntidades.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,8 +57,8 @@ public class ProyectoDaoJPA implements IProyectoDAO {
|
||||
query.setParameter("nombre", nombreProyecto);
|
||||
|
||||
proyecto = query.getSingleResult();
|
||||
}catch (NoResultException e) { // no hace nada, devuelve null
|
||||
}catch (Exception e) {
|
||||
} catch (NoResultException e) { // no hace nada, devuelve null
|
||||
} catch (Exception e) {
|
||||
throw new ProyectosIESException(e, this.getClass(), ProyectosIESException.ERROR_CONSULTA);
|
||||
}
|
||||
|
||||
@ -71,13 +67,13 @@ public class ProyectoDaoJPA implements IProyectoDAO {
|
||||
|
||||
@Override
|
||||
public void actualizarEntidad(Proyecto entidad) throws ProyectosIESException {
|
||||
EntityManager gestorEntidades= null;
|
||||
EntityManager gestorEntidades = null;
|
||||
EntityTransaction transaccion = null;
|
||||
|
||||
|
||||
try {
|
||||
gestorEntidades = GestorEntityManagerJPA.getEntityManager();
|
||||
transaccion = gestorEntidades.getTransaction();
|
||||
transaccion .begin();
|
||||
transaccion.begin();
|
||||
|
||||
if (gestorEntidades.contains(entidad))
|
||||
gestorEntidades.merge(entidad);
|
||||
@ -92,7 +88,7 @@ public class ProyectoDaoJPA implements IProyectoDAO {
|
||||
if (gestorEntidades != null) {
|
||||
gestorEntidades.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -104,7 +100,7 @@ public class ProyectoDaoJPA implements IProyectoDAO {
|
||||
@Override
|
||||
public void borrarEntidad(Integer clave) throws ProyectosIESException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user