public void destroy(String id) throws NonexistentEntityException, RollbackFailureException, Exception { EntityManager em = null; try { utx.begin(); em = getEntityManager(); TipoComparacion tipoComparacion; try { tipoComparacion = em.getReference(TipoComparacion.class, id); tipoComparacion.getIdComparador(); } catch (EntityNotFoundException enfe) { throw new NonexistentEntityException( "The tipoComparacion with id " + id + " no longer exists.", enfe); } em.remove(tipoComparacion); utx.commit(); } catch (Exception ex) { try { utx.rollback(); } catch (Exception re) { throw new RollbackFailureException( "An error occurred attempting to roll back the transaction.", re); } throw ex; } finally { if (em != null) { em.close(); } } }
public void edit(TipoComparacion tipoComparacion) throws NonexistentEntityException, RollbackFailureException, Exception { EntityManager em = null; try { utx.begin(); em = getEntityManager(); tipoComparacion = em.merge(tipoComparacion); utx.commit(); } catch (Exception ex) { try { utx.rollback(); } catch (Exception re) { throw new RollbackFailureException( "An error occurred attempting to roll back the transaction.", re); } String msg = ex.getLocalizedMessage(); if (msg == null || msg.length() == 0) { String id = tipoComparacion.getIdComparador(); if (findTipoComparacion(id) == null) { throw new NonexistentEntityException( "The tipoComparacion with id " + id + " no longer exists."); } } throw ex; } finally { if (em != null) { em.close(); } } }
public void create(TipoComparacion tipoComparacion) throws PreexistingEntityException, RollbackFailureException, Exception { EntityManager em = null; try { utx.begin(); em = getEntityManager(); em.persist(tipoComparacion); utx.commit(); } catch (Exception ex) { try { utx.rollback(); } catch (Exception re) { throw new RollbackFailureException( "An error occurred attempting to roll back the transaction.", re); } if (findTipoComparacion(tipoComparacion.getIdComparador()) != null) { throw new PreexistingEntityException( "TipoComparacion " + tipoComparacion + " already exists.", ex); } throw ex; } finally { if (em != null) { em.close(); } } }