Package org.apache.openjpa.kernel

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


            ((SelfReferencingCacheTestObject) l.get(0)).getStr());
    }

    public void testNullRelationOfSameTypeAsCandidate() {
        Broker broker = _factory.newBroker();
        Query q = broker.newQuery(JPQLParser.LANG_JPQL, "select a.o FROM " +
            SelfReferencingCacheTestObject.class.getSimpleName() +
            " a where a.o IS NULL");

        List l = (List) q.execute();
        assertNull(l.get(0));
View Full Code Here


        rangeTestHelper(20, 28);
    }

    private void rangeTestHelper(final int start, final int end) {
        Broker broker = _factory.newBroker();
        Query q = broker.newQuery(JPQLParser.LANG_JPQL, "Select a FROM " +
            CacheObjectAChild1.class.getSimpleName() + " a");
        q.setRange(start, end);

        // should not yet be in the cache
        CacheTestHelper.assertInCache(this, q, Boolean.FALSE);
View Full Code Here

        CacheTestHelper.assertInCache(this, q, Boolean.TRUE);

        broker.close();

        broker = _factory.newBroker();
        q = broker.newQuery(JPQLParser.LANG_JPQL, "Select a FROM " +
            CacheObjectAChild1.class.getSimpleName() + " a");
        q.setRange(start, end);
        CacheTestHelper.assertInCache(this, q, Boolean.TRUE);
        c = (Collection) q.execute();
        assertEquals(end - start, c.size());
View Full Code Here

        CacheTestHelper.assertInCache(this, q, Boolean.TRUE);
        c = (Collection) q.execute();
        assertEquals(end - start, c.size());

        // now check if a smaller range is in cache
        q = broker.newQuery(JPQLParser.LANG_JPQL, "Select a FROM " +
            CacheObjectAChild1.class.getSimpleName() + " a");
        q.setRange(start, end - 1);
        CacheTestHelper.assertInCache(this, q, Boolean.FALSE);
        c = (Collection) q.execute();
        assertEquals(end - start - 1, c.size());
View Full Code Here

        broker.close();
    }

    public void testResultClassIsCached() {
        Broker broker = _factory.newBroker();
        Query q = broker.newQuery(JPQLParser.LANG_JPQL, "Select a FROM " +
            CacheObjectAChild1.class.getSimpleName() + " a");
        q.setResultType(Object.class);
        Collection c = (Collection) q.execute();
        CacheTestHelper.iterate(c);
        CacheTestHelper.assertInCache(this, q, Boolean.TRUE);
View Full Code Here

        assertEquals(CacheObjectB.class, types[0]);
    }

    public void testSingleProjectionOfThisRelation() {
        Broker broker = getBroker();
        Query q = broker.newQuery(JPQLParser.LANG_JPQL, "select a FROM " +
            CacheObjectA.class.getSimpleName() + " a");
        Class[] types = q.getProjectionTypes();
        assertEquals(0, types.length);
    }
View Full Code Here

    }

    public void testNoResultClause() {
        Broker broker = getBroker();
        Query q =
            broker.newQuery(JPQLParser.LANG_JPQL, "select a FROM " +
                CacheObjectA.class.getSimpleName() + " a");
        Class[] types = q.getProjectionTypes();
        assertEquals(0, types.length);
    }
View Full Code Here

    public void testPCParameter() {
        Broker broker = _factory.newBroker();
        broker.begin();
        CacheObjectE e = (CacheObjectE) broker.find(_eId, true, null);
        Query q = broker.newQuery(JPQLParser.LANG_JPQL,
            "select a from " +
                CacheObjectJ.class.getSimpleName() + " a where a.e = :param");

        Collection c = (Collection) q.execute(new Object[]{ e });
        CacheTestHelper.iterate(c);
View Full Code Here

        CacheTestHelper.iterate(c);
        Object o = c.iterator().next();
        assertTrue(o instanceof CacheObjectJ);
        CacheTestHelper.assertInCache(this, q, Boolean.TRUE, new Object[]{ e });

        q = broker.newQuery(JPQLParser.LANG_JPQL,
            "select a from " +
                CacheObjectJ.class.getSimpleName() + " a where a.e = :param");

        c = (Collection) q.execute(new Object[]{ e });
        Object o2 = c.iterator().next();
View Full Code Here

            long q1p2;
            long q2p1;
            long q2p2;

            Broker broker = JPAFacadeHelper.toBroker(em);
            org.apache.openjpa.kernel.Query q = broker.newQuery(
                JPQLParser.LANG_JPQL, "Select a FROM "
                + CacheObjectA.class.getSimpleName() + " a");
            q.setCandidateExtent(broker.newExtent(CacheObjectA.class, false));
            start = System.currentTimeMillis();
            assertInCache(q, inCache);
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.