Пример #1
0
 @Override
 public AlumnoJPA BuscarAlumno(AlumnoJPA objalu) throws Exception {
   AlumnoJPA obj = null;
   Open();
   try {
     obj = em.find(AlumnoJPA.class, objalu.getNombre());
   } catch (Exception e) {
     System.out.println("Error DAO " + e.getMessage());
   } finally {
     Close();
   }
   return obj;
 }
Пример #2
0
 @Override
 public String EliminaAlumno(AlumnoJPA objalu) throws Exception {
   String msg = "";
   try {
     Open();
     em.getTransaction().begin();
     AlumnoJPA obj = null;
     obj = em.find(AlumnoJPA.class, objalu.getNombre());
     if (obj != null) em.remove(obj);
     em.getTransaction().commit();
     msg = "Se Elimino exitosamente";
   } catch (Exception e) {
     // TODO: handle exception
     System.out.println("DAO " + e.getMessage());
     msg = "DAO " + e.getMessage();
     em.getTransaction().rollback();
   } finally {
     Close();
   }
   return msg;
 }