Package org.apache.openjpa.persistence

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


        em.getTransaction().begin();
        intVer = em.find(IntVersionEntity.class, id);
        tsVer = em.find(TimestampVersionEntity.class, id);
        noVer = em.find(NoVersionEntity.class, id);
        em.detach(intVer);
        em.detach(tsVer);
        em.detach(noVer);
        em.getTransaction().commit();
        em.close();
       
        // Detach all internal implicitly with close()
View Full Code Here


        intVer = em.find(IntVersionEntity.class, id);
        tsVer = em.find(TimestampVersionEntity.class, id);
        noVer = em.find(NoVersionEntity.class, id);
        em.detach(intVer);
        em.detach(tsVer);
        em.detach(noVer);
        em.getTransaction().commit();
        em.close();
       
        // Detach all internal implicitly with close()
        em = emf.createEntityManager();
View Full Code Here

            em.clear();

            // find the entity
            p = em.find(Person.class, p.getId());
            // detach the entity
            em.detach(p);
            assertFalse(em.contains(p));

            // Set name to an invalid value (contains a space) to force a CVE upon merge+update
            p.setFirstName("First Name");
            em.getTransaction().begin();
View Full Code Here

            c = new ArrayList((Collection) q.getResultList());
            assertEquals(1, c.size());
            CacheObjectA a = (CacheObjectA) c.iterator().next();
            if (related)
                a.getRelatedArray();
            em.detach(a);
            assertEquals(ORIG_NAME, a.getName());
            q.closeAll();
        }
        finally {
            rollbackTx(em);
View Full Code Here

        assertTrue(em.contains(e20));
        assertFalse(em.isDetached(e20));
        verifySerializable(e20, true, false);
       
        // new openjpa-2.0.0 behavior, where detach() doesn't return updated entity, but does it in-place
        em.detach(e20);
        if (log.isTraceEnabled())
            log.trace("** testDetach20() - after detach");
        // in-place updated entity should not have any proxy classes and should be detached
        assertFalse(em.contains(e20));
        assertTrue(em.isDetached(e20));
View Full Code Here

            c = new ArrayList((Collection) q.getResultList());
            assertEquals(1, c.size());
            CacheObjectA a = (CacheObjectA) c.iterator().next();
            if (related)
                a.getRelatedArray();
            em.detach(a);
            assertEquals(ORIG_NAME, a.getName());
            q.closeAll();
        }
        finally {
            rollbackTx(em);
View Full Code Here

        endEm(pm);

        pm = getPM();
        c2 = (CalendarFields) pm.find(CalendarFields.class, id2);
        assertTimeZonesEquals(c1, c2);
        assertTimeZonesEquals(c1, (CalendarFields) pm.detach(c2));
        endEm(pm);
    }

    public void testCalendarQuery() {
        long time = 1136660560572L;
View Full Code Here

        plan.addFetchGroup("address.country");

        PCCompany company1 =
            (PCCompany) pm.find(PCCompany.class, _rootCompanyId);

        PCCompany company = (PCCompany) pm.detach(company1);
        assertTrue("company is equal company1", company != company1);
        Set departments = (Set) PCCompany.reflect(company, "departments");
        assertNotNull("department is null", departments);
        assertEquals("department size is not 2", 2, departments.size());
        PCDepartment dept = (PCDepartment) departments.iterator().next();
View Full Code Here

        owner = (DependentFieldsPC) pm.find(DependentFieldsPC.class, oid);
        if (mapped)
            assertEquals(2, owner.getDependentMappedList().size());
        else
            assertEquals(2, owner.getDependentInverseKeyList().size());
        DependentFieldsPC detached = (DependentFieldsPC) pm.detach(owner);
        endEm(pm);

        if (mapped) {
            assertEquals(2, detached.getDependentMappedList().size());
            detached.getDependentMappedList().clear();
View Full Code Here

        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        ManagedIface pcx = em.find(ManagedIface.class, oid);
        pc = em.detach(pcx);
        em.close();

        assertTrue(em.isDetached(pc));
        pc.setIntField(7);
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.