Java Reference
In-Depth Information
"The customer with id " + id
+ " no longer exists.");
}
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public void destroy(Long id) throws NonexistentEntityException,
RollbackFailureException, Exception {
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
Customer customer;
try {
customer = em.getReference(Customer.class, id);
customer.getId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException(
"The customer with id " + id
+ " no longer exists.", enfe);
}
em.remove(customer);
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();
}
 
Search WWH ::




Custom Search