public void destroy(Integer id) throws NonexistentEntityException { EntityManager em = null; try { em = getEntityManager(); em.getTransaction().begin(); MedioPago medioPago; try { medioPago = em.getReference(MedioPago.class, id); medioPago.getId(); } catch (EntityNotFoundException enfe) { throw new NonexistentEntityException( "The medioPago with id " + id + " no longer exists.", enfe); } em.remove(medioPago); em.getTransaction().commit(); } finally { if (em != null) { em.close(); } } }
public void create(MedioPago medioPago) throws PreexistingEntityException, Exception { EntityManager em = null; try { em = getEntityManager(); em.getTransaction().begin(); em.persist(medioPago); em.getTransaction().commit(); } catch (Exception ex) { if (findMedioPago(medioPago.getId()) != null) { throw new PreexistingEntityException("MedioPago " + medioPago + " already exists.", ex); } throw ex; } finally { if (em != null) { em.close(); } } }
public void edit(MedioPago medioPago) throws NonexistentEntityException, Exception { EntityManager em = null; try { em = getEntityManager(); em.getTransaction().begin(); medioPago = em.merge(medioPago); em.getTransaction().commit(); } catch (Exception ex) { String msg = ex.getLocalizedMessage(); if (msg == null || msg.length() == 0) { Integer id = medioPago.getId(); if (findMedioPago(id) == null) { throw new NonexistentEntityException( "The medioPago with id " + id + " no longer exists."); } } throw ex; } finally { if (em != null) { em.close(); } } }