Exemplo n.º 1
0
 @PreDestroy
 public void destroy() {
   System.out.println("In SingletonBean::destroy()");
   try {
     javax.transaction.TransactionSynchronizationRegistry r =
         (javax.transaction.TransactionSynchronizationRegistry)
             new InitialContext().lookup("java:comp/TransactionSynchronizationRegistry");
     if (r.getTransactionStatus() != javax.transaction.Status.STATUS_ACTIVE) {
       throw new IllegalStateException(
           "Transaction status is not STATUS_ACTIVE: " + r.getTransactionStatus());
     }
     FooEntity fe = new FooEntity("FOO");
     em.persist(fe);
   } catch (Exception e) {
     throw new EJBException(e);
   }
 }
Exemplo n.º 2
0
 @Asynchronous
 public void async() {
   FooEntity fe = new FooEntity("ASYNC");
   em.persist(fe);
 }
 public Collection getProducts(String catID) {
   return em.createQuery("SELECT p FROM Product p WHERE p.categoryID LIKE :categoryID")
       .setParameter("categoryID", catID)
       .getResultList();
 }
 public Collection getItems(String prodID) {
   return em.createQuery("SELECT i FROM Item i WHERE i.productID LIKE :productID")
       .setParameter("productID", prodID)
       .getResultList();
 }
 public Collection getCategories() {
   return em.createQuery("SELECT OBJECT(c) FROM Category_1 c").getResultList();
 }