Package org.apache.openjpa.persistence.merge.model

Examples of org.apache.openjpa.persistence.merge.model.Label


        EntityManager em = emf.createEntityManager();

        try {
            // Create simple bi-di graph
          ShipPackage p = new ShipPackage();
            Label l = new Label(p);
            p.setLabel(l);
           
            // Persist
            em.getTransaction().begin();
            em.persist(l);
            em.getTransaction().commit();

            // Detach
            em.clear();
            assertFalse(em.contains(l));
            assertFalse(em.contains(p));
            assertFalse(em.contains(l.getPackage()));
            assertFalse(em.contains(p.getLabel()));
           
            em.getTransaction().begin();
            Label mergedLabel = em.merge(l);

            assertFalse(mergedLabel == l);
            assertFalse(p == mergedLabel.getPackage());
            // Assert that the bi-directional relationship points to the
            // newly merged entity
            assertTrue(mergedLabel == mergedLabel.getPackage().getLabel());
            assertFalse(l == mergedLabel.getPackage().getLabel());
            em.remove(mergedLabel);
            em.getTransaction().commit();
        } finally {
            if (em != null) {
                if (em.getTransaction().isActive())
View Full Code Here

TOP

Related Classes of org.apache.openjpa.persistence.merge.model.Label

Copyright © 2018 www.massapicom. 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.