Compare commits
No commits in common. "44131f2b65a3c9f37762f6c4b2b80fe995e639c6" and "12b301d8fb53d385754fe7d2cfdf66243742f7eb" have entirely different histories.
44131f2b65
...
12b301d8fb
@ -1,8 +1,12 @@
|
||||
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;
|
||||
@ -18,15 +22,15 @@ import jakarta.persistence.TypedQuery;
|
||||
*/
|
||||
public class PatrocinadorDaoJPA implements IPatrocinadorDAO {
|
||||
@Override
|
||||
public void crearEntidad(Patrocinador entidad) throws ProyectosIESException {
|
||||
EntityManager gestorEntidades = null;
|
||||
public void crearEntidad(Patrocinador 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();
|
||||
@ -39,21 +43,20 @@ public class PatrocinadorDaoJPA implements IPatrocinadorDAO {
|
||||
if (gestorEntidades != null) {
|
||||
gestorEntidades.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actualizarEntidad(Patrocinador entidad) throws ProyectosIESException {
|
||||
EntityManager gestorEntidades = null;
|
||||
EntityTransaction transaccion = null;
|
||||
Transaction transaccion = null;
|
||||
Session sesion = null;
|
||||
|
||||
try {
|
||||
gestorEntidades = GestorEntityManagerJPA.getEntityManager();
|
||||
transaccion = gestorEntidades.getTransaction();
|
||||
transaccion.begin();
|
||||
|
||||
if (gestorEntidades.contains(entidad))
|
||||
gestorEntidades.merge(entidad);
|
||||
sesion = GestorSesionesHibernate.getSession();
|
||||
transaccion = sesion.beginTransaction();
|
||||
|
||||
if(sesion.contains(entidad))
|
||||
sesion.merge(entidad);
|
||||
|
||||
transaccion.commit();
|
||||
} catch (Exception e) {
|
||||
@ -62,10 +65,10 @@ public class PatrocinadorDaoJPA implements IPatrocinadorDAO {
|
||||
}
|
||||
throw new ProyectosIESException(e, this.getClass(), ProyectosIESException.ERROR_ACTUALIZACION);
|
||||
} finally {
|
||||
if (gestorEntidades != null) {
|
||||
gestorEntidades.close();
|
||||
if (sesion != null) {
|
||||
sesion.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -84,7 +87,7 @@ public class PatrocinadorDaoJPA implements IPatrocinadorDAO {
|
||||
|
||||
patrocinador = query.getSingleResult();
|
||||
} catch (NoResultException e) { // no hace nada, devuelve null
|
||||
} catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
throw new ProyectosIESException(e, this.getClass(), ProyectosIESException.ERROR_CONSULTA);
|
||||
}
|
||||
|
||||
@ -100,7 +103,8 @@ public class PatrocinadorDaoJPA implements IPatrocinadorDAO {
|
||||
@Override
|
||||
public void borrarEntidad(Integer clave) throws ProyectosIESException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
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;
|
||||
@ -18,15 +22,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();
|
||||
@ -39,7 +43,7 @@ public class ProyectoDaoJPA implements IProyectoDAO {
|
||||
if (gestorEntidades != null) {
|
||||
gestorEntidades.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,8 +61,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);
|
||||
}
|
||||
|
||||
@ -67,16 +71,15 @@ public class ProyectoDaoJPA implements IProyectoDAO {
|
||||
|
||||
@Override
|
||||
public void actualizarEntidad(Proyecto entidad) throws ProyectosIESException {
|
||||
EntityManager gestorEntidades = null;
|
||||
EntityTransaction transaccion = null;
|
||||
Transaction transaccion = null;
|
||||
Session sesion = null;
|
||||
|
||||
try {
|
||||
gestorEntidades = GestorEntityManagerJPA.getEntityManager();
|
||||
transaccion = gestorEntidades.getTransaction();
|
||||
transaccion.begin();
|
||||
sesion = GestorSesionesHibernate.getSession();
|
||||
transaccion = sesion.beginTransaction();
|
||||
|
||||
if (gestorEntidades.contains(entidad))
|
||||
gestorEntidades.merge(entidad);
|
||||
if (sesion.contains(entidad))
|
||||
sesion.merge(entidad);
|
||||
|
||||
transaccion.commit();
|
||||
} catch (Exception e) {
|
||||
@ -85,10 +88,10 @@ public class ProyectoDaoJPA implements IProyectoDAO {
|
||||
}
|
||||
throw new ProyectosIESException(e, this.getClass(), ProyectosIESException.ERROR_ACTUALIZACION);
|
||||
} finally {
|
||||
if (gestorEntidades != null) {
|
||||
gestorEntidades.close();
|
||||
if (sesion != null) {
|
||||
sesion.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -100,7 +103,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