Package org.apache.openjpa.kernel

Examples of org.apache.openjpa.kernel.Broker.newQuery()


        initEm.persist(e);
        endTx(initEm);
        endEm(initEm);

        Broker broker = JPAFacadeHelper.toBrokerFactory(factory).newBroker();
        org.apache.openjpa.kernel.Query q = broker.newQuery(
            JPQLParser.LANG_JPQL, "Select a FROM "
            + CacheObjectE.class.getSimpleName()
            + " a where a.str = 'e'");
        Collection c = (Collection) q.execute();
        for (Iterator iter = c.iterator(); iter.hasNext();)
View Full Code Here


        }
    }

    public void testEmptyResultsAreCached() {
        Broker broker = JPAFacadeHelper.toBrokerFactory(factory).newBroker();
        org.apache.openjpa.kernel.Query q = broker.newQuery(
            JPQLParser.LANG_JPQL, "Select a FROM "
            + CacheObjectAChild1.class.getSimpleName()
            + " a where a.name = 'testEmptyResultsAreCached'");
        Collection c = (Collection) q.execute();
        assertEquals(0, c.size());
View Full Code Here

    }

    public void testQueryResultTypesWithThis() {
        Broker broker = getBroker();
        Query q =
            broker.newQuery(JPQLParser.LANG_JPQL, "select a.name,a FROM " +
                CacheObjectA.class.getSimpleName() + " a");

        Class[] types = q.getProjectionTypes();
        assertEquals(2, types.length);
        assertEquals(String.class, types[0]);
View Full Code Here

        assertEquals(CacheObjectA.class, types[1]);
    }

    public void testQueryResultTypesWithRelated() {
        Broker broker = getBroker();
        Query q = broker
            .newQuery(JPQLParser.LANG_JPQL, "select a.name,a.relatedB FROM " +
                CacheObjectA.class.getSimpleName() + " a");

        //CacheObjectA.class,           "select name, relatedB");
        Class[] types = q.getProjectionTypes();
View Full Code Here

    }

    public void testSingleProjectionOfNonThisRelation() {
        Broker broker = getBroker();
        Query q =
            broker.newQuery(JPQLParser.LANG_JPQL, "select a.relatedB FROM " +
                CacheObjectA.class.getSimpleName() + " a");

        Class[] types = q.getProjectionTypes();
        assertEquals(1, types.length);
        assertEquals(CacheObjectB.class, types[0]);
View Full Code Here

        //OpenJPAQuery q = pm.createQuery("SELECT o FROM " +
        //c.getSimpleName() + "o WHERE o." + filter);
        String qstrng =
            "SELECT o FROM " + c.getSimpleName() + " o WHERE o." + filter;
        assertSize(size,
            (List) broker.newQuery(JPQLParser.LANG_JPQL, c, qstrng).execute());

        broker.commit();
        broker.close();

        broker = getBrokerFactory().newBroker();
View Full Code Here

        broker = getBrokerFactory().newBroker();
        broker.begin();
        // test again against a new PM, for good measure
        assertSize(size,
            (List) broker.newQuery(JPQLParser.LANG_JPQL, c, qstrng).execute());
        broker.rollback();

        broker.close();
    }
View Full Code Here

        // importantly, the identifier of the prepared query is the original
        // JPQL String
        String JPQL = JPQLParser.LANG_JPQL;
        String jpql = _id;
       
        org.apache.openjpa.kernel.Query newQuery = broker.newQuery(JPQL, jpql);
        newQuery.getFetchConfiguration().copy(_query.getFetchConfiguration());
        newQuery.compile();
        _query = new DelegatingQuery(newQuery, _em.getExceptionTranslator());
    }
   
View Full Code Here

        super.tearDown();
    }

    public void testMutatedDateParameter() {
        Broker broker = _factory.newBroker();
        Query q = broker.newQuery(JPQLParser.LANG_JPQL,
            "select a from " +
                CacheObjectAChild1.class.getSimpleName() +
                " a where a.date < :p_date");
        Date d = new Date();
        Collection c = (Collection) q.execute(new Object[]{ d });
View Full Code Here

    }

    public void testAggregateResultIsCached() {
        Broker broker = _factory.newBroker();
        Query q =
            broker.newQuery(JPQLParser.LANG_JPQL, "select max(a.age) FROM " +
                CacheObjectAChild1.class.getSimpleName() + " a");

        Object o = q.execute();
        assertEquals(Long.class, o.getClass());
        CacheTestHelper.assertInCache(this, q, Boolean.TRUE);
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.