Examples of DMCustomer


Examples of org.apache.openjpa.persistence.detachment.model.DMCustomer

    public void testLeaveProxy() {
        Object[] p = props;
        p[1] = "loaded(LiteAutoDetach=true,DetachProxyFields=false)";
        EntityManagerFactory iemf = createEMF(p);
        try {
            DMCustomer dc = new DMCustomer();
            Calendar cal = Calendar.getInstance();
            cal.setTimeInMillis(System.currentTimeMillis());
            dc.setCal(cal);

            EntityManager iem = iemf.createEntityManager();
            try {
                iem.getTransaction().begin();
                iem.persist(dc);
                iem.getTransaction().commit();
                Calendar beforeDetachCal = dc.getCal();
                iem.clear();
                Calendar afterDetachCal = dc.getCal();

                assertTrue(beforeDetachCal instanceof Proxy);
                assertTrue(afterDetachCal instanceof Proxy);
            } finally {
                if (iem.getTransaction().isActive()) {
View Full Code Here

Examples of org.apache.openjpa.persistence.detachment.model.DMCustomer

            iemf.close();
        }
    }

    public void testProxyClear() {
        DMCustomer dc = new DMCustomer();
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(System.currentTimeMillis());
        dc.setCal(cal);

        EntityManager iem = emf.createEntityManager();
        try {
            iem.getTransaction().begin();
            iem.persist(dc);
            iem.getTransaction().commit();
            Calendar beforeDetachCal = dc.getCal();
            iem.clear();
            Calendar afterDetachCal = dc.getCal();

            assertTrue(beforeDetachCal instanceof Proxy);
            assertFalse(afterDetachCal instanceof Proxy);
        } finally {
            if (iem.getTransaction().isActive()) {
View Full Code Here

Examples of org.apache.openjpa.persistence.detachment.model.DMCustomer

    }
   
    public void testDetachRemovesEntityAndCascadedRelationFromContext() {
        em.getTransaction().begin();
       
        DMCustomer pc = em.find(DMCustomer.class, root.getId());
        List<DMCustomerInventory> inventories = pc.getCustomerInventories();
        DMItem item = inventories.get(0).getItem();
       
        assertNotDetached(pc);
        for (DMCustomerInventory i : inventories) assertNotDetached(i);
        assertNotDetached(item);  
       
        em.detach(pc);
       
        assertDetached(pc);
        for (DMCustomerInventory i : inventories) assertDetached(i);
       
        em.getTransaction().rollback();
       
        assertNotNull(pc.getFirstName());
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.detachment.model.DMCustomer

        assertNotNull(pc.getFirstName());
    }
   
    public void testDetachingDirtyEntityDoesNotImplicitlyFlush() {
        em.getTransaction().begin();
        DMCustomer pc = em.find(DMCustomer.class, root.getId());
        String original = pc.getLastName();
        pc.setLastName("Changed That Should not be Saved");
        em.detach(pc);
        em.getTransaction().commit();
       
        DMCustomer pc2 = em.find(DMCustomer.class, root.getId());
        assertNotNull(pc2);
        assertEquals(original, pc2.getLastName());
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.detachment.model.DMCustomer

        assertEquals(original, pc2.getLastName());
    }
   
    public void testDetachingNewEntityIsIgnored() {
        em.getTransaction().begin();
        DMCustomer pc = em.find(DMCustomer.class, root.getId());
        List<DMCustomerInventory> inventories = pc.getCustomerInventories();
       
        DMCustomer newPC = new DMCustomer();
        newPC.setCustomerInventories(inventories);
        for (DMCustomerInventory inventory : inventories)
            inventory.setCustomer(newPC);
       
        em.detach(newPC);
        for (DMCustomerInventory inventory : inventories) {
View Full Code Here

Examples of org.apache.openjpa.persistence.detachment.model.DMCustomer

        em.getTransaction().rollback();
    }
   
    public void testDetachingDetachedEntityIsIgnored() {
        em.getTransaction().begin();
        DMCustomer pc = em.find(DMCustomer.class, root.getId());
        List<DMCustomerInventory> inventories = pc.getCustomerInventories();
       
        em.detach(pc);
        DMCustomer detached = pc;
        assertDetached(detached);
        for (DMCustomerInventory inventory : inventories) {
            assertDetached(inventory);
        }
       
        List<DMCustomerInventory> newInventories =
            new ArrayList<DMCustomerInventory>();
        newInventories.addAll(inventories);
        DMCustomerInventory newInventory = new DMCustomerInventory();
        newInventory.setCustomer(detached);
        newInventories.add(newInventory);
        detached.setCustomerInventories(newInventories);
        em.persist(newInventory);
        assertNotDetached(newInventory);
       
        em.detach(detached);
        assertDetached(detached);
View Full Code Here

Examples of org.apache.openjpa.persistence.detachment.model.DMCustomer

    }
   
    public void testManagedEntityContinuesToReferDetachedEntities() {
        em.getTransaction().begin();
       
        DMCustomer pc = em.find(DMCustomer.class, root.getId());
        List<DMCustomerInventory> inventories = pc.getCustomerInventories();
        DMItem item = inventories.get(1).getItem();
       
        em.detach(inventories.get(0));
       
        DMCustomerInventory attached0 = inventories.get(0);
        DMCustomerInventory attached1 = inventories.get(1);
       
        assertSame(pc.getCustomerInventories().get(0), attached0);
        assertSame(pc.getCustomerInventories().get(1), attached1);
       
        em.getTransaction().rollback();
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.detachment.model.DMCustomer

       
        DMCustomerInventory inventory1 = new DMCustomerInventory();
        DMCustomerInventory inventory2 = new DMCustomerInventory();
        inventory1.setItem(item1); inventory1.setQuantity(10);
        inventory2.setItem(item2); inventory2.setQuantity(20);
        DMCustomer customer = new DMCustomer();
        customer.setFirstName("Detached"); customer.setLastName("Customer");
        customer.setCustomerInventories(Arrays.asList(
            new DMCustomerInventory[]{inventory1,inventory2}));
        inventory1.setCustomer(customer);
        inventory2.setCustomer(customer);
       
        em.getTransaction().begin();
View Full Code Here

Examples of org.apache.openjpa.persistence.detachment.model.DMCustomer

        root = createData();
    }

    public void testPendingClear() {
        EntityManager em = emf.createEntityManager();
        DMCustomer dm = em.find(DMCustomer.class, root.getId());
        dm.setLastName(System.currentTimeMillis() + "--last");
        em.clear();
        em.getTransaction().begin();
        // Pre OPENJPA-2136 this commit call would fail.
        em.getTransaction().commit();
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.detachment.model.DMCustomer

    public void testLeaveProxy() {
        Object[] p = props;
        p[1] = "loaded(LiteAutoDetach=true,DetachProxyFields=false)";
        EntityManagerFactory iemf = createEMF(p);
        try {
            DMCustomer dc = new DMCustomer();
            Calendar cal = Calendar.getInstance();
            cal.setTimeInMillis(System.currentTimeMillis());
            dc.setCal(cal);

            EntityManager iem = iemf.createEntityManager();
            try {
                iem.getTransaction().begin();
                iem.persist(dc);
                iem.getTransaction().commit();
                Calendar beforeDetachCal = dc.getCal();
                iem.clear();
                Calendar afterDetachCal = dc.getCal();

                assertTrue(beforeDetachCal instanceof Proxy);
                assertTrue(afterDetachCal instanceof Proxy);
               
                // Make sure that we get rid of the StateManager.
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.