Package org.apache.openjpa.kernel

Examples of org.apache.openjpa.kernel.Query.execute()


    public void testNonNullRelatedPCIsCached() {
        Broker broker = _factory.newBroker();
        Query q = broker.newQuery(JPQLParser.LANG_JPQL, "select a.e FROM " +
            CacheObjectJ.class.getSimpleName() + " a where a.e  is not null");

        Collection c = (Collection) q.execute();
        CacheTestHelper.iterate(c);
        CacheTestHelper.assertInCache(this, q, Boolean.TRUE);

        c = (Collection) q.execute();
        assertEquals(CacheObjectE.class, c.iterator().next().getClass());
View Full Code Here


        Collection c = (Collection) q.execute();
        CacheTestHelper.iterate(c);
        CacheTestHelper.assertInCache(this, q, Boolean.TRUE);

        c = (Collection) q.execute();
        assertEquals(CacheObjectE.class, c.iterator().next().getClass());
    }

    public void testNonNullRelatedPCAndProjectionIsCached() {
        Broker broker = _factory.newBroker();
View Full Code Here

        Query q =
            broker.newQuery(JPQLParser.LANG_JPQL, "select a.str,a.e FROM " +
                CacheObjectJ.class.getSimpleName() +
                " a where a.e is not null");

        Collection c = (Collection) q.execute();
        CacheTestHelper.iterate(c);
        CacheTestHelper.assertInCache(this, q, Boolean.TRUE);

        c = (Collection) q.execute();
        Object[] result = (Object[]) c.iterator().next();
View Full Code Here

        Collection c = (Collection) q.execute();
        CacheTestHelper.iterate(c);
        CacheTestHelper.assertInCache(this, q, Boolean.TRUE);

        c = (Collection) q.execute();
        Object[] result = (Object[]) c.iterator().next();
        assertEquals(2, result.length);
        assertEquals(String.class, result[0].getClass());
        assertEquals(CacheObjectE.class, result[1].getClass());
    }
View Full Code Here

                SelfReferencingCacheTestObject.class.getSimpleName() +
                " a where a.str='foo'");

        List l = null;
        try {
            l = (List) q.execute();
            assertEquals(CacheObjectAChild1.class, l.get(0).getClass());
        } catch (UserException ue) {
            //bug(1150, "embedded-field projections cause exception");
            ue.printStackTrace();
            return;
View Full Code Here

            CacheObjectAChild1.class.getSimpleName() + " a");
        q.setRange(start, end);

        // should not yet be in the cache
        CacheTestHelper.assertInCache(this, q, Boolean.FALSE);
        Collection c = (Collection) q.execute();

        // iterate the results. This will cause the query to be
        // enlisted in the cache.
        CacheTestHelper.iterate(c);
        assertEquals(end - start, c.size());
View Full Code Here

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

        // now check if a smaller range is in cache
        q = broker.newQuery(JPQLParser.LANG_JPQL, "Select a FROM " +
            CacheObjectAChild1.class.getSimpleName() + " a");
View Full Code Here

        // 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());
        broker.close();
    }

    public void testResultClassIsCached() {
View Full Code Here

    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

        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);
        Object o = c.iterator().next();
        assertTrue(o instanceof CacheObjectJ);
        CacheTestHelper.assertInCache(this, q, Boolean.TRUE, new Object[]{ e });
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.