Package javax.persistence

Examples of javax.persistence.EntityManager.find()


        entityManager.persist(book);
        // makes a rollback
        entityManager.getTransaction().rollback();
        entityManager.close();
        // verifies if the container made the rollback
        Book bookResult = entityManager.find(Book.class, new Integer(ID));
        assertNull(bookResult, "The container did not make the rollback");
    }

    /**
     * Verifies if the serRollbackOnly works.
View Full Code Here


            logger.info("The bean threw an expected exception");
        }
        entityManager.close();

        // verifies if the transaction was rolled back
        Book bookResult = entityManager.find(Book.class, new Integer(ID));
        assertNull(bookResult, "The container did not make the rollback");
    }

    /**
     * Verifies if the commit works.
View Full Code Here

                "The transaction is not marked as rollback, but the container returned true for the method getRollbackOnly()");
        // makes a commit
        entityManager.getTransaction().commit();
        entityManager.close();
        // verifies if the bean is persistent.
        Book bookResult = entityManager.find(Book.class, new Integer(ID));
        assertNotNull(bookResult, "The container did not make the rollback");

    }
}
View Full Code Here

               TestEntity test = new TestEntity("Hello", "World");
               em.persist(test);
            }
            else
            {
               TestEntity test = em.find(TestEntity.class, "Hello");
               resp.setContentType("text/plain");
               PrintWriter out = resp.getWriter();
               out.print(test.getDescription());
               out.close();
            }
View Full Code Here

        
         new FacesRequest() {
             protected void invokeApplication()
             {
                 EntityManager em = (EntityManager) getValue("#{entityManager}");
                 Product found = em.find(Product.class ,p.getProductId());
                 assertNotNull("find by id", found);
                 assertEquals("id", p.getProductId(), found.getProductId());
                 assertEquals("title", "test", found.getTitle());
        
                 em.remove(found);            
View Full Code Here

        
          new FacesRequest() {
              protected void invokeApplication()
              {
                  EntityManager em = (EntityManager) getValue("#{entityManager}");
                  Product found = em.find(Product.class ,p.getProductId());

                  assertNull("deleted product", found);            
              }
           }.run();
         
View Full Code Here

                WikiComment newComment = new WikiComment();

                newComment.setAreaNumber(d.getAreaNumber());
                newComment.setDerivedName(d);
                newComment.setWikiname(WikiUtil.convertToWikiName(newComment.getName()));
                newComment.setCreatedBy(em.find(User.class, 1l));

                newComment.setSubject("Seven");
                newComment.setContent("Testcomment Seven");
                newComment.setUseWikiText(true);
View Full Code Here

                WikiDirectory newDir = new WikiDirectory();
                newDir.setName("FFF");
                newDir.setWikiname("FFF");
                newDir.setAreaNumber(d.getAreaNumber());
                newDir.setCreatedBy(em.find(User.class, 1l));
                newDir.setParent(d);

                em.persist(newDir);
                em.flush();
View Full Code Here

         try
         {
            Integer id = Integer.parseInt(value);
            if (id != null)
            {
               return entityManager.find(Film.class, id);
            }
         }
         catch (NumberFormatException e)
         {
         }
View Full Code Here

                WikiDocument newDoc = new WikiDocument();
                newDoc.setName("Four");
                newDoc.setWikiname("Four");
                newDoc.setAreaNumber(d.getAreaNumber());
                newDoc.setCreatedBy(em.find(User.class, 1l));
                newDoc.setContent("Testdocument Four");
                newDoc.setParent(d);

                em.persist(newDoc);
                em.flush();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.