Examples of EntityManager


Examples of javax.persistence.EntityManager

  public void fill() throws JRException
  {
    long start = System.currentTimeMillis();
    // create entity manager factory for connection with database
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("pu1", new HashMap());
    EntityManager em = emf.createEntityManager();

    try
    {
      Map parameters = getParameters(em);
     
      JasperFillManager.fillReportToFile("build/reports/JRMDbReport.jasper", parameters);

      em.close();
     
      System.err.println("Filling time : " + (System.currentTimeMillis() - start));
    }
    finally
    {
      if (em.isOpen())
        em.close();
      if (emf.isOpen())
        emf.close();
    }
  }
View Full Code Here

Examples of javax.persistence.EntityManager

            protected void testComponents()
                throws Exception
            {
                Product p = new Product();

                EntityManager em = (EntityManager) getValue("#{entityManager}");
                try {
                    em.persist(p);
                    fail("empty product persisted");
                } catch (PersistenceException e) {
                    // good
                }                
            }           
View Full Code Here

Examples of javax.persistence.EntityManager

         p.setTitle("test");

         new FacesRequest() {
            protected void invokeApplication()
            {
                EntityManager em = (EntityManager) getValue("#{entityManager}");               
                em.persist(p);           
            }
           
          
         }.run();
        
         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);            
             }
          }.run();
        
          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

Examples of javax.persistence.EntityManager

         InitialContext ctx = new InitialContext();
        
         t = (UserTransaction) ctx.lookup("UserTransaction");
         t.begin();
     
         EntityManager em = (EntityManager) Component.getInstance("entityManager", true);
        
         List<Auction> auctions = em.createQuery("select a from Auction a").getResultList();
        
         Calendar cal = new GregorianCalendar();
        
         Random r = new Random(System.currentTimeMillis());
        
         for (Auction auction : auctions)
         {
            cal.setTime(auction.getEndDate());
            cal.add(Calendar.DATE, r.nextInt(7));
            cal.add(Calendar.MINUTE, 30 + r.nextInt(1410));
            auction.setEndDate(cal.getTime());
            auction.setStatus(Auction.STATUS_COMPLETED);
            em.merge(auction);

            AuctionEndAction auctionEnd = (AuctionEndAction) Component.getInstance(AuctionEndAction.class, true);
            auctionEnd.endAuction(auction.getAuctionId(), auction.getEndDate());
         }
        
View Full Code Here

Examples of javax.persistence.EntityManager

    @Test
    public void directoryURL() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiDirectory d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 3l)
                                .getSingleResult();

                assert d.getPermURL(".lace").equals("3.lace");
                assert d.getWikiURL().equals("CCC");

                d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 4l)
                                .getSingleResult();

                assert d.getPermURL(".lace").equals("4.lace");
                assert d.getWikiURL().equals("CCC/DDD");

                d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 1l)
                                .getSingleResult();

                assert d.getPermURL(".lace").equals("1.lace");
                assert d.getWikiURL().equals("");
View Full Code Here

Examples of javax.persistence.EntityManager

    @Test
    public void commentURL() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiComment c = (WikiComment)
                        em.createQuery("select c from WikiComment c where c.id = :id")
                                .setParameter("id", 10l)
                                .getSingleResult();

                assert c.getPermURL(".lace").equals("6.lace#comment10");
                assert c.getWikiURL().equals("CCC/One#comment10");
View Full Code Here

Examples of javax.persistence.EntityManager

    @Test
    public void uploadURL() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiUpload u = (WikiUpload)
                        em.createQuery("select u from WikiUpload u where u.id = :id")
                                .setParameter("id", 30l)
                                .getSingleResult();

                assert u.getPermURL(".lace").equals("service/File/30");
                assert u.getWikiURL().equals("service/File/30");
View Full Code Here

Examples of javax.persistence.EntityManager

    @Test
    public void findAllComments() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiDocument d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d where d.id = :id")
                                .setParameter("id", 6l)
                                .getSingleResult();
                assert d.getName().equals("One");

                List<WikiComment> comments =
                        em.createQuery("select c from WikiComment c where c.parent = :doc order by c.createdOn asc")
                        .setParameter("doc", d)
                        .getResultList();

                assert comments.size() == 6;
View Full Code Here

Examples of m33.entities.EntityManager

    //entities = new EntityManager();
  }

  public void gameReset() {
    // should I create a reset method in entityManager?
    entities = new EntityManager();
   
    hero = new Hero();
    hero.load("hero.png");

    level = new Map(entities);
View Full Code Here

Examples of org.terasology.entitySystem.entity.EntityManager

                return new PojoPrefab(uri, data);
            }
        });
        NetworkSystem networkSystem = mock(NetworkSystem.class);
        when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
        EntityManager em = new EntitySystemBuilder().build(moduleManager.getEnvironment(), networkSystem, new ReflectionReflectFactory());
        prefabManager = new PojoPrefabManager();
    }
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.