Package org.apache.openjpa.persistence

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


    }

    public void testBulkDelete() {
        OpenJPAEntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List result = em.createQuery("SELECT o FROM AllFieldTypes o")
            .getResultList();
        assertEquals(1, result.size());
        em.createQuery("DELETE FROM AllFieldTypes o").executeUpdate();
        em.getTransaction().commit();
        em.close();
View Full Code Here


        OpenJPAEntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        List result = em.createQuery("SELECT o FROM AllFieldTypes o")
            .getResultList();
        assertEquals(1, result.size());
        em.createQuery("DELETE FROM AllFieldTypes o").executeUpdate();
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
View Full Code Here

    public void testBulkUpdate() {
        OpenJPAEntityManager em = emf.createEntityManager();

        em.getTransaction().begin();
        List result = em.createQuery("SELECT o FROM AllFieldTypes o "
            + "WHERE o.intField = 0").getResultList();
        assertEquals(1, result.size());
        em.createQuery("UPDATE AllFieldTypes o SET o.intField = 10")
            .executeUpdate();
        em.getTransaction().commit();
View Full Code Here

        em.getTransaction().begin();
        List result = em.createQuery("SELECT o FROM AllFieldTypes o "
            + "WHERE o.intField = 0").getResultList();
        assertEquals(1, result.size());
        em.createQuery("UPDATE AllFieldTypes o SET o.intField = 10")
            .executeUpdate();
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
View Full Code Here

    public void testEagerOwnerOneToManyQuery() {
        sql.clear();

        OpenJPAEntityManager em = emf.createEntityManager();
        OpenJPAQuery q = em.createQuery("SELECT o FROM BidiParent o "
            + "ORDER BY o.name ASC");
        q.getFetchPlan().addField(BidiParent.class, "oneToManyChildren");
        q.getFetchPlan().addField(BidiChild.class, "oneToManyParent");
        List<BidiParent> res = (List<BidiParent>) q.getResultList();
View Full Code Here

    public void testEagerOwnerOneToOneQuery() {
        sql.clear();

        OpenJPAEntityManager em = emf.createEntityManager();
        OpenJPAQuery q = em.createQuery("SELECT o FROM BidiParent o "
            + "ORDER BY o.name ASC");
        q.getFetchPlan().addField(BidiParent.class, "oneToOneChild");
        q.getFetchPlan().addField(BidiChild.class, "oneToOneParent");
        List<BidiParent> res = (List<BidiParent>) q.getResultList();
View Full Code Here

    public void testEagerNonOwnerOneToOneQuery() {
        sql.clear();

        OpenJPAEntityManager em = emf.createEntityManager();
        OpenJPAQuery q = em.createQuery("SELECT o FROM BidiParent o "
            + "ORDER BY o.name ASC");
        q.getFetchPlan().addField(BidiParent.class, "oneToOneChild");
        q.getFetchPlan().addField(BidiChild.class, "oneToManyParent");
        List<BidiParent> res = (List<BidiParent>) q.getResultList();
View Full Code Here

   
    public void testWithSingleParamNoParentheses() {
        OpenJPAEntityManager em = _emf.createEntityManager();
        String jpql = "select a from Address a where a.zip in :p";
        Integer zip = ORIGINAL_ZIPS.get(4);
        TypedQuery<Address> q = em.createQuery(jpql, Address.class);
        q.setParameter("p", zip);
        try {
            List<Address> result = q.getResultList();
            fail("Expected error in execution because single-valued parameter not acceptable without parenthese");
        } catch (ArgumentException e) {
View Full Code Here

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

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