Java Reference
In-Depth Information
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Long id = customer.getId();
if (findCustomer(id) == null) {
throw new NonexistentEntityException(
"The customer with id " + id +
" no longer exists.");
}
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public void destroy(Long id) throws NonexistentEntityException {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
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);
em.getTransaction().commit();
} finally {
if (em != null) {
em.close();
}
}
}
public List<Customer> findCustomerEntities() {
return findCustomerEntities(true, -1, -1);
}
public List<Customer> findCustomerEntities(int maxResults,
int firstResult) {
return findCustomerEntities(false, maxResults, firstResult);
}
 
Search WWH ::




Custom Search