Package org.apache.openjpa.persistence

Examples of org.apache.openjpa.persistence.OpenJPAEntityManager.clear()


        PObject pc2 = new PObject(); pc2.setValue(55);
        em.persist(pc1);
        em.persist(pc2);
        em.getTransaction().commit();
        Object newId = em.getObjectId(pc2);
        em.clear();
       
        PObject newP = em.find(PObject.class, newId);
        assertNotNull(newP);
        assertEquals("newslice", SlicePersistence.getSlice(newP));
    }
View Full Code Here


            // Create and persist a new entity
            Person p = createPerson(em);
            em.getTransaction().begin();
            em.persist(p);
            em.getTransaction().commit();
            em.clear();

            // find the entity
            p = em.find(Person.class, p.getId());
           
            // modify the entity and merge
View Full Code Here

            em.getTransaction().begin();
            p.setFirstName("NewFirst");
            // merge should not throw a CVE
            p = em.merge(p);
            em.getTransaction().commit();
            em.clear();
            p = em.find(Person.class, p.getId());
            assertEquals("NewFirst", p.getFirstName());
            getLog().trace("testMergeExisting() Part 1 of 2 passed");
        } catch (Exception e) {
            // unexpected
View Full Code Here

            // Create and persist a new entity
            Person p = createPerson(em);
            em.getTransaction().begin();
            em.persist(p);
            em.getTransaction().commit();
            em.clear();

            // find the entity
            p = em.find(Person.class, p.getId());
            // detach the entity
            em.detach(p);
View Full Code Here

        List list = q.getResultList();
        assertEquals(2, list.size());
        assertEquals(2, sql.size());

        sql.clear();
        em.clear();
        for (int i = 0; i < list.size(); i++) {
            Publisher p = (Publisher) list.get(i);
            Set<Magazine> magazines = p.getMagazineCollection();
            assertEquals(4, magazines.size());
            for (Iterator iter = magazines.iterator(); iter.hasNext();) {
View Full Code Here

        List list = q.getResultList();
        assertEquals(_nPeople, list.size());
        assertEquals(7, sql.size());

        sql.clear();
        em.clear();
        for (int i = 0; i < list.size(); i++) {
            PPerson p = (PPerson) list.get(i);
            Collection<PPhone> phones = p.getPhones();
            assertEquals(_nPhones, phones.size());
            for(PPhone phone : p.getPhones()) {
View Full Code Here

        }
        em.getTransaction().begin();
        em.persist(c);
        em.flush();
        em.getTransaction().commit();
        em.clear();

        c = em.find(Customer.class, ck);
        orders = c.getOrders();
        assertEquals(numOrdersPerCustomer - 1, orders.size());
        count = count(Order.class);
View Full Code Here

        c = em.find(Customer.class, ck);
        orders = c.getOrders();
        assertEquals(numOrdersPerCustomer - 1, orders.size());
        count = count(Order.class);
        assertEquals(numOrdersPerCustomer * numCustomers - 1, count);
        em.clear();

        // OrphanRemoval: remove target: setOrders to null
        c = em.find(Customer.class, ck);
        c.setOrders(null);
        em.getTransaction().begin();
View Full Code Here

        c.setOrders(null);
        em.getTransaction().begin();
        em.persist(c);
        em.flush();
        em.getTransaction().commit();
        em.clear();

        count = count(Order.class);
        assertEquals(numOrdersPerCustomer * (numCustomers - 1), count);
        c = em.find(Customer.class, ck);
        orders = c.getOrders();
View Full Code Here

        Customer c = em.find(Customer.class, ck);
        em.getTransaction().begin();
        em.remove(c);
        em.flush();
        em.getTransaction().commit();
        em.clear();

        int count = count(Order.class);
        assertEquals(numOrdersPerCustomer * (numCustomers - 1), count);
        em.close();
    }
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.