Package org.apache.openjpa.persistence

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


        assertTrue(em.contains(e20));
        assertFalse(em.isDetached(e20));
        verifySerializable(e20, true, false);
       
        // Test new detachCopy() method added in 2.0.0
        Entity20 e20copy = em.detachCopy(e20);
        if (log.isTraceEnabled())
            log.trace("** TestDetachCopy20() - after detachCopy");
        // verify e20 is same as above
        assertTrue(em.contains(e20));
        assertFalse(em.isDetached(e20));
View Full Code Here


    public void testDetachCopy() {
        OpenJPAEntityManager em = emf.createEntityManager();
        LRSEntity lrs = em.find(LRSEntity.class, id);
        assertLRS(lrs, "lrs");
        lrs = em.detachCopy(lrs);
        assertEquals("lrs", lrs.getName());
        assertNull(lrs.getLRSList());
        em.close();
        assertMerge(lrs);
    }
View Full Code Here

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

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

        assertTrue(em.isDetached(pc));
        pc.setIntField(7);
View Full Code Here

        assertTrue(em.contains(e20));
        assertFalse(em.isDetached(e20));
        verifySerializable(e20, true, false);
       
        // Test new detachCopy() method added in 2.0.0
        Entity20 e20copy = em.detachCopy(e20);
        if (log.isTraceEnabled())
            log.trace("** TestDetachCopy20() - after detachCopy");
        // verify e20 is same as above
        assertTrue(em.contains(e20));
        assertFalse(em.isDetached(e20));
View Full Code Here

        endEm(pm);

        pm = getPM();
        c2 = pm.find(CalendarFields.class, id2);
        assertTimeZonesEquals(c1, c2);
        assertTimeZonesEquals(c1, pm.detachCopy(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.detachCopy(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

    public void testAttachDetachSuccess()
        throws Exception {
        OpenJPAEntityManager pm1 = getPM(false, false);
        LockGroupPC pc1 = (LockGroupPC) pm1.find(LockGroupPC.class, oid);
        Object detached = pm1.detachCopy(pc1);
        startTx(pm1);
        pc1.setLockGroup0IntField(1);
        pc1.setUnlockedStringField("pm1 changed value");
        endTx(pm1);
        endEm(pm1);
View Full Code Here

    public void testAttachDetachFailure()
        throws Exception {
        OpenJPAEntityManager pm1 = getPM(false, false);
        LockGroupPC pc1 = (LockGroupPC) pm1.find(LockGroupPC.class, oid);
        Object detached = pm1.detachCopy(pc1);
        startTx(pm1);
        pc1.setLockGroup0IntField(1);
        endTx(pm1);
        endEm(pm1);
View Full Code Here

        OpenJPAEntityManager pm = getPM();
        AttachB b = pm.find(AttachB.class, oid);

        assertNotNull("b is null in testDetach", b);

        b = (AttachB) pm.detachCopy(b);
        endEm(pm);

        assertTrue(pm.isDetached(b));
        assertEquals(5, b.getAint());
        assertEquals("5", b.getBstr());
View Full Code Here

        pm.getFetchPlan().addFetchGroup("all");
        AttachB b = pm.find(AttachB.class, oid);

        assertNotNull("b is null in testDetachWithGroups", b);

        b = (AttachB) pm.detachCopy(b);
        endEm(pm);

        assertTrue(pm.isDetached(b));
        assertEquals("b.getAint() not 5", 5, b.getAint());
        assertEquals("b.getAint() not 5str", "5", b.getBstr());
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.