Package org.apache.openjpa.persistence

Examples of org.apache.openjpa.persistence.OpenJPAEntityManager.createQuery()


        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);
View Full Code Here


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

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

        query.setParameter(1, "runt1");
        int ok = query.executeUpdate();

        assertEquals(1, ok);
View Full Code Here

        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();

        assertEquals(1, upd);
View Full Code Here

        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager ();
        em.getTransaction().begin();
        Query query = em.createQuery("select o from ManagedIface o " +
            "where o.intField = 14");
        pc = (ManagedIface) query.getSingleResult();
        assertEquals(14, pc.getIntField());
        em.remove(pc);
        em.getTransaction().commit();
View Full Code Here

        assertEquals(5, pc.getEmbed().getEmbedIntField());
        em.close();

        em = emf.createEntityManager();
        em.getTransaction().begin();
        Query q = em.createQuery("select o from ManagedInterfaceOwner o " +
            "where o.iface.intFieldSup = 3 and o.embed.embedIntField = 5");
        pc = (ManagedInterfaceOwner) q.getSingleResult();
        assertEquals(3, pc.getIFace().getIntFieldSup());
        assertEquals(5, pc.getEmbed().getEmbedIntField());
View Full Code Here

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

        OpenJPAQuery q = em.createQuery("SELECT o FROM RuntimeTest1 o");
        List c = q.getResultList();
        Iterator i = c.iterator();
        if (!(i.hasNext()))
            fail("Iterator should have had next()");
        q.closeAll();
View Full Code Here

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

        OpenJPAQuery q = em.createQuery("SELECT o FROM RuntimeTest1 o");
        List c = q.getResultList();
        Iterator i = c.iterator();
        if (!(i.hasNext()))
            fail("Iterator should have had next()");
        q.closeAll();
View Full Code Here

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

        String query = "SELECT o FROM RuntimeTest1 o";
        OpenJPAQuery q = em.createQuery(query);
        q.getFetchPlan().setFetchBatchSize(5);
        List c = q.getResultList();

        Iterator i = c.iterator();
        if (!(i.hasNext()))
View Full Code Here

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

        String query = "SELECT o FROM RuntimeTest1 o";
        OpenJPAQuery q = em.createQuery(query);
        q.getFetchPlan().setFetchBatchSize(-1);

        List c = q.getResultList();

        Iterator i = c.iterator();
View Full Code Here

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

        String query = "SELECT o FROM RuntimeTest1 o";

        Collection c = (Collection) em.createQuery(query).getResultList();
        if (!(c instanceof List))
            fail("Collection (" + c.getClass() + ") should have "
                + "been a List instance");

        endTx(em);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.