
Untitled
By: a guest on
May 3rd, 2012 | syntax:
None | size: 0.69 KB | hits: 15 | expires: Never
public List<Product> findAllProducts(){
Query query = null;
List<Product> products = null;
try {
Context ctx = (Context) new javax.naming.InitialContext().lookup("java:comp/env");
utx.begin();
EntityManager em = (EntityManager) ctx.lookup("persistence/LogicalName");
query = em.createQuery("SELECT * FROM CUSTOMERS");
products = query.getResultList();
utx.commit();
} catch(Exception e) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught", e);
throw new RuntimeException(e);
}
return products;
}