Package org.apache.openjpa.persistence.kernel.common.apps

Examples of org.apache.openjpa.persistence.kernel.common.apps.RuntimeTest1


        deleteAll(RuntimeTest1.class);

        OpenJPAEntityManager pm = getPM();
        startTx(pm);

        RuntimeTest1 b = new RuntimeTest1("STRING", 10);
        RuntimeTest2 c = new RuntimeTest2("STRING2", 11);
        pm.persist(b);
        pm.persist(c);

        endTx(pm);
View Full Code Here


        OpenJPAEntityManager pm = getPM();
        startTx(pm);

        // create a test object
        RuntimeTest1 a = new RuntimeTest1("foo", 3);
        pm.persist(a);

        endTx(pm);

        oid = pm.getObjectId(a);
View Full Code Here

    public void testNotDirtyAfterSameChange() {
        OpenJPAEntityManager pm = getPM();
        startTx(pm);

        RuntimeTest1 a = (RuntimeTest1) pm.find(RuntimeTest1.class, oid);
        a.setStringField(a.getStringField());
        OpenJPAStateManager sm = getStateManager(a, pm);
        FieldMetaData fmd = sm.getMetaData().getField("stringField");
        assertTrue(sm.getDirty().get(fmd.getIndex()) == false);

        endTx(pm);
View Full Code Here

                broker.getLifecycleEventManager().hasLoadListeners(
                    new RuntimeTest4("foo"),
                    repos.getMetaData(RuntimeTest4.class, null, true)));
            assertFalse("there should be listeners def for runtimetest1",
                broker.getLifecycleEventManager().hasLoadListeners
                    (new RuntimeTest1(), repos.getMetaData
                        (RuntimeTest1.class, null, true)));
            broker.close();
        } finally {
            pmfSPI.removeLifecycleListener(listener);
        }
View Full Code Here

    }

    public void setUp() {
        deleteAll(RuntimeTest1.class);

        RuntimeTest1 pc = new RuntimeTest1();
        pc.setIntField(1);
        pc.setIntField1(1);
        _oid = persist(pc);
    }
View Full Code Here

        OpenJPAEntityManager pm = getPM();
        pm.setOptimistic(false);
        pm.validateChanges();        // no-op outside trans
        startTx(pm);

        RuntimeTest1 pc = (RuntimeTest1) pm.find(RuntimeTest1.class, _oid);
        pc.setIntField1(100);

        RuntimeTest1 npc = new RuntimeTest1();
        npc.setIntField(2);
        npc.setIntField1(2);
        pm.persist(npc);
        pm.validateChanges();

        assertEquals(100, pc.getIntField1());
        assertTrue(pm.isPersistent(npc));

        pc.setIntField1(200);
        npc.setIntField1(300);
        endTx(pm);

        assertEquals(200, pc.getIntField1());
        assertTrue(pm.isPersistent(npc));
        assertEquals(300, npc.getIntField1());
        endEm(pm);
    }
View Full Code Here

        OpenJPAEntityManager pm = getPM();
        pm.setOptimistic(false);
        pm.validateChanges();        // no-op outside trans
        startTx(pm);

        RuntimeTest1 pc = (RuntimeTest1) pm.find(RuntimeTest1.class, _oid);
        pc.setIntField1(100);

        RuntimeTest1 npc = new RuntimeTest1();
        pm.persist(npc);
        Object noid = pm.getObjectId(npc);

        pm.validateChanges();
        assertEquals(100, pc.getIntField1());
        assertTrue(pm.isPersistent(npc));

        pc.setIntField1(200);
        npc.setIntField1(300);
        rollbackTx(pm);

        assertEquals(1, pc.getIntField1());
        assertFalse(pm.isPersistent(npc));
        assertEquals(0, npc.getIntField1());
        endEm(pm);

        pm = getPM();
        try {
            RuntimeTest1 temp =
                (RuntimeTest1) pm.find(RuntimeTest1.class, noid);
            fail("Object should not exist." + temp.getIntField() + "::" +
                temp.getIntField1());
        } catch (Exception jonfe) {
        }
        endEm(pm);
    }
View Full Code Here

        pm.setOptimistic(true);
        pm.validateChanges();        // no-op outside trans
        startTx(pm);
        boolean hasConn = hasConnection(pm);

        RuntimeTest1 pc = (RuntimeTest1) pm.find(RuntimeTest1.class, _oid);
        pc.setIntField1(100);

        RuntimeTest1 npc = new RuntimeTest1();
        npc.setIntField(2);
        npc.setIntField1(2);
        pm.persist(npc);

        pm.validateChanges();
        if (!hasConn)
            assertFalse(hasConnection(pm));

        assertEquals(100, pc.getIntField1());
        assertTrue(pm.isPersistent(npc));

        pc.setIntField1(200);
        npc.setIntField1(300);
        endTx(pm);

        assertEquals(200, pc.getIntField1());
        assertTrue(pm.isPersistent(npc));
        assertEquals(300, npc.getIntField1());
        endEm(pm);
    }
View Full Code Here

        pm.setOptimistic(true);
        pm.validateChanges();        // no-op outside trans
        startTx(pm);
        boolean hasConn = hasConnection(pm);

        RuntimeTest1 pc = (RuntimeTest1) pm.find(RuntimeTest1.class, _oid);
        pc.setIntField1(100);

        RuntimeTest1 npc = new RuntimeTest1();
        pm.persist(npc);
        Object noid = pm.getObjectId(npc);

        pm.validateChanges();
        if (!hasConn)
            assertFalse(hasConnection(pm));

        assertEquals(100, pc.getIntField1());
        assertTrue(pm.isPersistent(npc));

        pc.setIntField1(200);
        npc.setIntField1(300);
        rollbackTx(pm);

        assertEquals(1, pc.getIntField1());
        assertFalse(pm.isPersistent(npc));
        assertEquals(0, npc.getIntField1());
        endEm(pm);

        pm = getPM();
        try {
            RuntimeTest1 temp =
                (RuntimeTest1) pm.find(RuntimeTest1.class, noid);

            fail("Object should not exist." + temp.getIntField() + "::" +
                temp.getIntField1());
        } catch (Exception jonfe) {
        }
    }
View Full Code Here

    public void testSimple() {
        // test create
        {
            OpenJPAEntityManager pm = getPM();
            startTx(pm);
            pm.persist(new RuntimeTest1("testSimple", 12));
            endTx(pm);
            endEm(pm);
        }

        // test Query
        {
            OpenJPAEntityManager pm = getPM();
            startTx(pm);
            String theQuery =
                "SELECT r FROM RuntimeTest1 r WHERE r.stringField = \'testSimple\'";
            OpenJPAQuery query = pm.createQuery(theQuery);
            List list = query.getResultList();
            assertSize(1, list);
            endTx(pm);
            endEm(pm);
        }

        // test Update
        {
            OpenJPAEntityManager pm = getPM();
            startTx(pm);
            String theQuery =
                "SELECT r FROM RuntimeTest1 r WHERE r.stringField = \'testSimple\'";
            OpenJPAQuery query = pm.createQuery(theQuery);
            RuntimeTest1 toUpdate = (RuntimeTest1) query.getSingleResult();
            toUpdate.setStringField("testSimple2");
            endTx(pm);
            endEm(pm);

            pm = getPM();
            startTx(pm);
View Full Code Here

TOP

Related Classes of org.apache.openjpa.persistence.kernel.common.apps.RuntimeTest1

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.