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

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


        OpenJPAEntityManager em =
            (OpenJPAEntityManager) currentEntityManager();
        startTx(em);

        runt1 = new RuntimeTest1(1);
        runt1.setStringField("runt1");
        runt1.setSelfOneOne(new RuntimeTest1(2));
        runt2 = new RuntimeTest2(3);
        runt2.setStringField("runt2");

        ent = new Entity1(23, "UPDATEST", 100);
View Full Code Here


    public void testUpdate1() {
        OpenJPAEntityManager em =
            (OpenJPAEntityManager) currentEntityManager();
        startTx(em);

        RuntimeTest1 ret = em.find(RuntimeTest1.class, em.getObjectId(runt1));

        assertNotNull(ret);
        assertEquals("runt1", ret.getStringField());
        assertNotNull(ret.getSelfOneOne());

        String ejbqlUpdate =
            "UPDATE RuntimeTest1 x SET x.stringField = :strngfld WHERE x.stringField = :stdfield";
        int updatedEntities = em.createQuery(ejbqlUpdate)
            .setParameter("strngfld", "runner13")
            .setParameter("stdfield", "runt1")
            .executeUpdate();

        assertEquals(1, updatedEntities);

        endTx(em);

        RuntimeTest1 ret2 = em.find(RuntimeTest1.class, em.getObjectId(runt1));
        em.refresh(ret2);

        assertNotNull(ret2);
        assertEquals("runner13", ret2.getStringField());

        endEm(em);
    }
View Full Code Here

    public void testUpdate2() {
        OpenJPAEntityManager em =
            (OpenJPAEntityManager) currentEntityManager();
        startTx(em);

        RuntimeTest1 run = em.find(RuntimeTest1.class, em.getObjectId(runt1));
        assertNotNull(run);
        assertEquals("runt1", run.getStringField());
        assertNotNull(run.getSelfOneOne());

        String ejbqlUpdate = "UPDATE RuntimeTest1 x " +
            "SET x.stringField = :strngfld " +
            "WHERE x.stringField = :field";
        int upEntities = em.createQuery(ejbqlUpdate)
            .setParameter("strngfld", "upd")
            .setParameter("field", "runt1")
            .executeUpdate();

        assertEquals(1, upEntities);

        endTx(em);

        em = (OpenJPAEntityManager) currentEntityManager();
        startTx(em);

        RuntimeTest1 inst = em.find(RuntimeTest1.class, em.getObjectId(runt1));
        em.refresh(inst);

        assertNotNull(inst);
        assertEquals("upd", inst.getStringField());

        endTx(em);
        endEm(em);
    }
View Full Code Here

    public void testDelete1() {
        OpenJPAEntityManager em =
            (OpenJPAEntityManager) currentEntityManager();
        startTx(em);

        RuntimeTest1 run = em.find(RuntimeTest1.class, em.getObjectId(runt1));
        assertNotNull(run);
        assertEquals("runt1", run.getStringField());
        assertNotNull(run.getSelfOneOne());

        String ejbdelUpdate = "DELETE  FROM RuntimeTest1 s " +
            "WHERE s.stringField = :strngfld";
        int delEntity = em.createQuery(ejbdelUpdate)
            .setParameter("strngfld", "runt1")
            .executeUpdate();

        assertEquals(1, delEntity);

        RuntimeTest1 del = em.find(RuntimeTest1.class, em.getObjectId(runt1));
        assertNull(del);

        endTx(em);
        endEm(em);
    }
View Full Code Here

    public void testDelete2() {
        OpenJPAEntityManager em =
            (OpenJPAEntityManager) currentEntityManager();
        startTx(em);

        RuntimeTest1 run = em.find(RuntimeTest1.class, em.getObjectId(runt1));
        assertNotNull(run);
        assertEquals("runt1", run.getStringField());
        assertNotNull(run.getSelfOneOne());

        String ejbdelUpdate =
            "DELETE  FROM RuntimeTest1 r WHERE r.stringField = ?1";
        Query query = em.createQuery(ejbdelUpdate);
View Full Code Here

        deleteAll(RuntimeTest1.class);

        OpenJPAEntityManager em =
            (OpenJPAEntityManager) currentEntityManager();
        startTx(em);
        em.persist(new RuntimeTest1("TestQueryResults1", 10));
        em.persist(new RuntimeTest1("TestQueryResults3", 10));
        em.persist(new RuntimeTest1("TestQueryResults5", 10));
        em.persist(new RuntimeTest3("TestQueryResults2", 10));
        em.persist(new RuntimeTest3("TestQueryResults4", 10));
        em.persist(new RuntimeTest3("TestQueryResults6", 10));
        endTx(em);
        endEm(em);
View Full Code Here

        int run1 = 10;
        int run2 = 15;

        for (int i = 0; i < run1; i++) {
            RuntimeTest1 rt = new RuntimeTest1(i);
            rt.setStringField("foo " + i);
            em.persist(rt);
        }

        for (int i = 10; i < run2; i++) {
            em.persist(new RuntimeTest2(i));
View Full Code Here

    public void setUp() {
        deleteAll(RuntimeTest1.class);
        OpenJPAEntityManager pm = getEM();
        startTx(pm);
        pm.persist(new RuntimeTest1("foo", 3));
        pm.persist(new RuntimeTest1("bar", 15));
        pm.persist(new RuntimeTest1("baz", -8));
        pm.persist(new RuntimeTest1("baz2", 45)); // 45 is '-'
        pm.persist(new RuntimeTest1("3", (int) '4'));
        endTx(pm);
        endEm(pm);

        // make sure everything is working as expected for the base case.
        assertEquals(1, helper("intField = -8"));
View Full Code Here

        int run1 = 10;
        int run2 = 15;

        for (int i = 0; i < run1; i++) {
            RuntimeTest1 rt = new RuntimeTest1(i);
            rt.setStringField("foo " + i);
            em.persist(rt);
        }

        for (int i = 10; i < run2; i++) {
            em.persist(new RuntimeTest2(i));
View Full Code Here

        deleteAll(RuntimeTest1.class);

        OpenJPAEntityManager em =
            (OpenJPAEntityManager) currentEntityManager();
        startTx(em);
        em.persist(new RuntimeTest1("TestQueryResults1", 10));
        em.persist(new RuntimeTest1("TestQueryResults3", 10));
        em.persist(new RuntimeTest1("TestQueryResults5", 10));
        em.persist(new RuntimeTest3("TestQueryResults2", 10));
        em.persist(new RuntimeTest3("TestQueryResults4", 10));
        em.persist(new RuntimeTest3("TestQueryResults6", 10));
        endTx(em);
        endEm(em);
View Full Code Here

TOP

Related Classes of org.apache.openjpa.persistence.query.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.