Package javax.persistence

Examples of javax.persistence.EntityManager.clear()


            List resultList = q1.getResultList();
            assertNotNull(resultList);
           
            List <EParent> pList = new ArrayList<EParent>();
            pList.addAll(resultList);
            em.clear();                     
            assertNotEquals(0, pList.size());
           
            EParent pFind = pList.get(0);
           
            assertNotNull(pFind);
View Full Code Here


        em.getTransaction().begin();
        em.persist(entity);
        em.getTransaction().commit();

        em.clear();
        PropertyAccessCapitalizationOldBehavior persistentEntity =
            em.find(PropertyAccessCapitalizationOldBehavior.class, entity.getId());
        assertEquals(entity, persistentEntity);
    }
}
View Full Code Here

    public void testJPQLNoFetch() {
        EntityManager em = emf.createEntityManager();
        List<Department> ds = em.createQuery("SELECT DISTINCT d FROM Department d WHERE d.deptno = 10").getResultList();
        System.out.println("-- testJPQLNoFetch -----");
        em.clear();
        Assert.assertEquals(1, ds.size());
        for (Department x : ds) {
            Assert.assertNull(x.getEmployees());
            Assert.assertNull(x.getEmployee2s());
            System.out.println(x);
View Full Code Here

        EntityManager em = emf.createEntityManager();
        List<Department> ds =
            em.createQuery("SELECT DISTINCT d FROM Department d LEFT JOIN FETCH d.employee2s " + "WHERE d.deptno = 10")
                .getResultList();
        System.out.println("-- testJPQLOneFetch -----");
        em.clear();
        Assert.assertEquals(1, ds.size());
        for (Department x : ds) {
            Assert.assertNull(x.getEmployees());
            Assert.assertNotNull(x.getEmployee2s());
            Assert.assertEquals(2, x.getEmployee2s().size());
View Full Code Here

            TypedQuery<ContactInfo> query = em.createQuery(sql, ContactInfo.class);
            query.setParameter("id", p.getId());
            query.getSingleResult();

            em.clear();
            query = em.createQuery(sql, ContactInfo.class);
            query.setParameter("id", p.getId());
            query.getSingleResult();

        } finally {
View Full Code Here

        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        em.persist(entity);
        em.getTransaction().commit();
        em.clear();

        // Find the entity and retrieve the objectId we use internally
        EmbeddedIdEntity persistedEntity = em.find(EmbeddedIdEntity.class, id);
        StateManagerImpl smi = ((StateManagerImpl) ((PersistenceCapable) persistedEntity).pcGetStateManager());
        Object oid = smi.getObjectId();
View Full Code Here

      operationSuccessfull = true;
    }
    finally {
      commitOrRollback( operationSuccessfull );
    }
    em.clear();

    getTransactionManager().begin();
    operationSuccessfull = false;
    try {
      firstSong = em.find( Song.class, firstSong.getId() );
View Full Code Here

      operationSuccessful = true;
    }
    finally {
      commitOrRollback( operationSuccessful );
    }
    em.clear();

    // load mug and lid; lid should inherit id from the mug
    getTransactionManager().begin();
    operationSuccessful = false;
    try {
View Full Code Here

      ok = true;
    }
    finally {
      commitOrRollback( ok );
    }
    em.clear();

    getTransactionManager().begin();
    ok = false;
    try {
      Animal animal = em.find( Animal.class, jungleKing.getId() );
View Full Code Here

    }
    finally {
      commitOrRollback( operationSuccessfull );
    }

    em.clear();
    getTransactionManager().begin();
    operationSuccessfull = false;
    try {
      DistributedRevisionControl dvcs = em.find( DistributedRevisionControl.class, git.getId() );
      assertThat( dvcs ).isNotNull();
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.