Java Reference
In-Depth Information
utx.begin();
em = getEntityManager();
em.persist(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();
}
}
}
public void edit(Customer customer) throws
NonexistentEntityException, RollbackFailureException, Exception
{
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
customer = em.merge(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);
}
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Long id = customer.getId();
if (findCustomer(id) == null) {
throw new NonexistentEntityException(
 
Search WWH ::




Custom Search