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

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


        // set retainvalues to false so that we can ensure that the
        // data in the database is correct, and that we're not just
        // testing that the JVM data is correct.
        OpenJPAEntityManager pm = getPM(true, false);
        startTx(pm);
        ModInstanceCallbackTests a = new ModInstanceCallbackTests("foo", 10);
        pm.persist(a);

        // by setting the name to 'bar', the jdoPreStore() invocation
        // will set the parent to a new object. This ensures that new
        // objects created in jdoPreStore() make their way into the DB
        // during commit.
        if (before) {
            a.setStringField("bar");
            pm.flush();
        } else {
            pm.flush();
            a.setStringField("bar");
        }
        endTx(pm);
        assertTrue("a.preStoreCalled is false", a.preStoreCalled);
        assertNotNull("a.getOneOne is null", a.getOneOne());
        assertTrue("getOneOne().getstrngfld.equals(jdoPrestore) is false",
            a.getOneOne().getStringField().equals("jdoPreStore"));
    }
View Full Code Here


        // set retainvalues to false so that we can ensure that the
        // data in the database is correct, and that we're not just
        // testing that the JVM data is correct.
        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)
                pm.persist(parent);

            a.setOneOne(parent);

            if (before)
                pm.flush();
        }

        endTx(pm);
        assertTrue("a.preStoreCalled is false", a.preStoreCalled);
        assertNotNull("a.getOneOne is null", a.getOneOne());
        if (!multi)
            assertTrue("a.getOneOne().getStringField().equals(baz) is false",
                a.getOneOne().getStringField().equals("baz"));
        else {
            assertTrue(
                "a.getOneOne().getStringField().equals(newParent) is false",
                a.getOneOne().getStringField().equals("newParent"));

            // if multi, then we really should delete the baz
            // parent. This isn't happening right now.
            // ### should be a bug
            //assertTrue (JDOHelper.isDeleted (oldParent));
View Full Code Here

TOP

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

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.