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

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


    }

    public void testGetSingleList() {
        EntityManager em = currentEntityManager();

        Entity1 ret =
            (Entity1) em.createQuery("SELECT o FROM Entity1 o WHERE o.pk = 2")
                .getSingleResult();

        assertNotNull(ret);
        assertEquals("string2", ret.getStringField());
        assertEquals(4, ret.getIntField());

        endEm(em);
    }
View Full Code Here


        List l = em.createQuery("Select object(o) from Entity1 o order by o.pk")
            .setFirstResult(3)
            .getResultList();

        Entity1 ent = (Entity1) l.get(0);

        assertNotNull(ent);
        assertEquals("string3", ent.getStringField());
        assertEquals(5, ent.getIntField());

        endEm(em);
    }
View Full Code Here

    public void testSimple() throws java.io.IOException {
        // test create
        {
            EntityManager em = currentEntityManager();
            startTx(em);
            em.persist(new Entity1(0, "testSimple", 12));
            endTx(em);
            endEm(em);
        }

        // test Query
View Full Code Here

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

        ent = new Entity1(23, "UPDATEST", 100);

        em.persist(runt1);
        em.persist(runt2);
        em.persist(ent);
View Full Code Here

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

        Entity1 ent = em.find(Entity1.class, 23);

        assertNotNull(ent);
        assertEquals("UPDATEST", ent.getStringField());

        int upd = em.createQuery(
            "UPDATE Entity1 e SET e.stringField = \'UPDATEFAILED\' WHERE " +
                "e.pk = 23").executeUpdate();
View Full Code Here

    public void testSimple() throws java.io.IOException {
        // test create
        {
            EntityManager em = currentEntityManager();
            startTx(em);
            em.persist(new Entity1(0, "testSimple", 12));
            endTx(em);
            endEm(em);
        }

        // test Query
        {
            EntityManager em = currentEntityManager();
            startTx(em);
            em.persist(new Entity1(1, "testSimple", 12));
            List<Entity1> l =
                em.createQuery("SELECT o FROM Entity1 o " + "WHERE o.stringField = 'testSimple'")
                    .getResultList();
            assertSize(2, l);
            rollbackTx(em);
View Full Code Here

TOP

Related Classes of org.apache.openjpa.persistence.query.common.apps.Entity1

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.