Package org.apache.openjpa.persistence

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


            assertTrue(em.isDetached(entity));
           
            entity.setValue("val2");
            //X entity.setValue2("val2");

            entity = em.merge(entity);

            // the merge invoked a PostLoad, and this should now STILL be 'val1'
            assertEquals("val1", PostLoadListenerImpl.postLoadValue);
            em.getTransaction().commit();
View Full Code Here


            // reopen a new EntityManager
            em = emf.createEntityManager();
            em.getTransaction().begin();
            entity.setValue("val3");

            entity = em.merge(entity);

            // the merge invoked a PostLoad, and this should now STILL be 'val1'
            assertEquals("val2", PostLoadListenerImpl.postLoadValue);
            em.getTransaction().commit();
View Full Code Here

        assertTrue(em.isDetached(pc));
        pc.setIntField(7);

        em = emf.createEntityManager();
        em.getTransaction().begin();
        em.merge(pc);
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        pc = em.find(ManagedIface.class, oid);
View Full Code Here

            assertTrue("ValidationMode",
                conf.getValidationMode().equalsIgnoreCase("AUTO"));

            Person p = createPerson(em);
            em.getTransaction().begin();
            p = em.merge(p);
            em.getTransaction().commit();
            getLog().trace("testMergeNew() Part 1 of 2 passed");
        } catch (Exception e) {
            // unexpected
            getLog().trace("testMergeNew() Part 1 of 2 failed");
View Full Code Here

        assertNotNull(em);       
        try {
            Person p = createPerson(em);
            em.getTransaction().begin();
            p.setLastName(null)// Force a CVE
            p = em.merge(p);
            getLog().trace("testMergeNew() Part 2 of 2 failed");
            fail("Expected a ConstraintViolationException");
        } catch (ConstraintViolationException e) {
            // expected
            getLog().trace("Caught expected ConstraintViolationException = " + e);
View Full Code Here

           
            // modify the entity and merge
            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");
View Full Code Here

            // Set name to an invalid value (contains a space) to force a CVE upon merge+update
            p.setFirstName("First Name");
            em.getTransaction().begin();
            try {
                p = em.merge(p);
            } catch (Throwable t) {
                fail("Did not expect a CVE upon merge.");
            }
            // Commit should throw a CVE
            em.getTransaction().commit();
View Full Code Here

            // Merge the entity so that it can be removed.
            em.getTransaction().begin();
            ndge.setDgName(null);
            ndge.setNdgName("Some name");
            ndge = em.merge(ndge);
            em.getTransaction().commit();
           
            try {
                // Update the entity with null value and remove the entity. 
                // validation should not fail on pre-remove
View Full Code Here

            detached.getDependentInverseKeyList().clear();
        }

        pm = (OpenJPAEntityManager) currentEntityManager();
        startTx(pm);
        owner = (DependentFieldsPC) pm.merge(detached);
        if (mapped)
            assertEquals(0, owner.getDependentMappedList().size());
        else
            assertEquals(0, owner.getDependentInverseKeyList().size());
        endTx(pm);
View Full Code Here

        assertTrue(em.isDetached(pc));
        pc.setIntField(7);

        em = emf.createEntityManager();
        em.getTransaction().begin();
        em.merge(pc);
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        pc = em.find(ManagedIface.class, oid);
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.