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

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


        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 = 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

        deleteAll(RuntimeTest1.class);

        OpenJPAEntityManager pm = getPM();
        startTx(pm);
        for (int i = 0; i < 50; i++)
            pm.persist(new RuntimeTest1("open results #" + i, i));
        endTx(pm);
        endEm(pm);
    }
View Full Code Here

        deleteAll(RuntimeTest1.class);

        OpenJPAEntityManager pm = getPM();
        startTx(pm);
        RuntimeTest1 pc = new RuntimeTest1("str1", 1);
        pm.persist(pc);
        endTx(pm);
        _oid = pm.getObjectId(pc);
        endEm(pm);
    }
View Full Code Here

    }

    private void clearTest(boolean retain) {
        OpenJPAEntityManager pm = getPM(retain);
        OpenJPAEntityManagerFactory pmf = pm.getEntityManagerFactory();
        RuntimeTest1 pc = (RuntimeTest1) pm.find(RuntimeTest1.class, _oid);

        OpenJPAEntityManager pm2 = getPM();
        RuntimeTest1 pc2 = (RuntimeTest1) pm2.find(RuntimeTest1.class, _oid);
        startTx(pm2);
        pc2.setStringField("str2");
        pc2.setIntField1(2);
        endTx(pm2);
        endEm(pm2);

        startTx(pm);
        // tickle the object so that it enters the transaction
View Full Code Here

    private void optLockTest(boolean retain) {
        OpenJPAEntityManager pm1 = getPM(retain);
        OpenJPAEntityManagerFactory pmf = pm1.getEntityManagerFactory();

        startTx(pm1);
        RuntimeTest1 pc1 = (RuntimeTest1) pm1.find(RuntimeTest1.class, _oid);
        endTx(pm1);

        OpenJPAEntityManager pm2 = getPM(retain);
        startTx(pm2);
        RuntimeTest1 pc2 = (RuntimeTest1) pm2.find(RuntimeTest1.class, _oid);
        pc2.setStringField("str3");
        pc2.setIntField1(3);
        endTx(pm2);

        startTx(pm1);
        pc1.setStringField("str4");
        pc1.setIntField1(4);
View Full Code Here

    }

    public void testLocales() {
        EntityManager pm = currentEntityManager();
        startTx(pm);
        RuntimeTest1 t1 = new RuntimeTest1(1);
        t1.setLocaleField(new Locale(Locale.FRANCE.getCountry(),
            Locale.FRENCH.getLanguage()));
        pm.persist(t1);
        pm.persist(new RuntimeTest1(2));
        endTx(pm);
        endEm(pm);

        pm = currentEntityManager();
        List c = findAll(RuntimeTest1.class, pm);
        assertEquals(2, c.size());

        boolean foundNull = false;
        boolean foundFrance = false;
        Locale locale;

        for (Iterator iter = c.iterator(); iter.hasNext();) {
            t1 = (RuntimeTest1) iter.next();
            locale = t1.getLocaleField();
            if (locale == null)
                foundNull = true;
            else if (
                (locale.getCountry().equals(Locale.FRANCE.getCountry())) &&
                    (locale.getLanguage().equals(Locale.FRANCE.getLanguage())))
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

        deleteAll(RuntimeTest2.class);

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

        RuntimeTest1 a = new RuntimeTest1("STRING", 10);
        RuntimeTest2 b = new RuntimeTest2("STRING2", 11);
        pm.persist(a);
        pm.persist(b);
        _id = a.getIntField();
        _id2 = b.getIntField();

        endTx(pm);
        endEm(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.