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

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


        OpenJPAEntityManager pm = getPM(true, false);
        startTx(pm);
        ModInstanceCallbackTests a = new ModInstanceCallbackTests("foo", 10);
        pm.persist(a);

        ModRuntimeTest1 parent = new ModRuntimeTest1("baz", 11);
        if (!before)
            pm.flush();

        if (persist)
            pm.persist(parent);

        a.setOneOne(parent);

        if (before)
            pm.flush();

        ModRuntimeTest1 oldParent = null;
        if (multi) {
            oldParent = parent;
            parent = new ModRuntimeTest1("newParent", 12);

            if (!before)
                pm.flush();

            if (persist)
View Full Code Here


    }

    public void testDeleteNew() {
        OpenJPAEntityManager pm = getPM(true, false);
        startTx(pm);
        ModRuntimeTest1 a = new ModRuntimeTest1("foo", 10);
        pm.persist(a);
        pm.remove(a);
        assertState(a, PCState.PNEWDELETED, pm);
    }
View Full Code Here

    public void testOptimisticLockGivesCorrectError() {
        OpenJPAEntityManager pm1 = getPM(true, false);
        OpenJPAEntityManager pm2 = getPM(true, false);

        ModRuntimeTest1 a1 = new ModRuntimeTest1("foo", 10);
        startTx(pm1);
        pm1.persist(a1);
        endTx(pm1);

        ModRuntimeTest1 a2 = (ModRuntimeTest1)
            pm2.find(ModRuntimeTest1.class, pm2.getObjectId(a1));
        startTx(pm2);
        a2.setStringField("foobar");
        endTx(pm2);

        startTx(pm1);
        a1.setStringField("foobarbaz");
        try {
View Full Code Here

        assertSize(0, flushPM.createNativeQuery("stringField == '" + name + "'",
            ModRuntimeTest1.class));
        assertSize(0, readPM.createNativeQuery("stringField == '" + name + "'",
            ModRuntimeTest1.class));

        ModRuntimeTest1 a = new ModRuntimeTest1(name, randomInt().intValue());

        flushPM.persist(a);

        assertSize(0, readPM.createNativeQuery("name == '" + name + "'",
            ModRuntimeTest1.class));
View Full Code Here

    public void testEmptyFlush() {
        OpenJPAEntityManager pm = getPM();
        TListener listener = new TListener();
        ((OpenJPAEntityManagerSPI) pm).addTransactionListener(listener);
        startTx(pm);
        ModRuntimeTest1 pc = new ModRuntimeTest1();
        pm.persist(pc);
        pm.flush();
        assertEquals(1, listener.flushes);
        assertEquals(0, listener.commits);

        pm.flush();
        assertEquals(1, listener.flushes);
        assertEquals(0, listener.commits);

        pc.setIntField(3);
        pm.flush();
        assertEquals(2, listener.flushes);
        assertEquals(0, listener.commits);

        endTx(pm);
View Full Code Here

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

        ModRuntimeTest2 b = pm.find(ModRuntimeTest2.class, _id);
        ModRuntimeTest1 parent = b.getSelfOneOne();
        pm.remove(b);
        assertPersistent(b, true, false, true, true);
        assertPersistent(parent, true, false, false, false);

        endTx(pm);
View Full Code Here

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

        ModRuntimeTest2 b = pm.find(ModRuntimeTest2.class, _id);
        ModRuntimeTest1 parent = b.getSelfOneOne();
        pm.remove(b);
        assertPersistent(b, true, false, true, true);
        assertPersistent(parent, true, false, false, false);

        rollbackTx(pm);
View Full Code Here

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

        ModRuntimeTest2 b = pm.find(ModRuntimeTest2.class, _id);
        ModRuntimeTest1 parent = b.getSelfOneOne();
        assertNotNull("parent is null", parent);
        pm.remove(b);

        endTx(pm);

        // parent should be valid
        assertEquals("PARENT", parent.getStringField());

        // 'b' should be cleared
        assertNull(b.getStringField());
        assertEquals(0, b.getIntField());
        assertNull(b.getSelfOneOne());
View Full Code Here

        throws Exception {
        OpenJPAEntityManager pm = getPM(true, false);
        startTx(pm);

        ModRuntimeTest2 b = pm.find(ModRuntimeTest2.class, _id);
        ModRuntimeTest1 parent = b.getSelfOneOne();
        assertNotNull("parent is null", parent);
        pm.remove(b);

        endTx(pm);

        // parent should be valid
        assertEquals("PARENT", parent.getStringField());

        // 'b' should not be cleared JPA 2.0 "3.2.3 Removal"
        assertNotNull(b.getStringField());
        assertNotEquals(0, b.getIntField());
        assertNotNull(b.getSelfOneOne());
View Full Code Here

        throws Exception {
        OpenJPAEntityManager pm = getPM(true, true);
        startTx(pm);

        ModRuntimeTest2 b = pm.find(ModRuntimeTest2.class, _id);
        ModRuntimeTest1 parent = b.getSelfOneOne();

        assertNotNull("parent is null", parent);
        pm.remove(b);

        endTx(pm);

        // parent should be valid
        assertEquals("PARENT", parent.getStringField());

        // 'b' should not be cleared JPA 2.0 "3.2.3 Removal"
        assertNotNull(b.getStringField());
        assertNotEquals(0, b.getIntField());
        assertNotNull(b.getSelfOneOne());
View Full Code Here

TOP

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

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.