Package org.apache.openjpa.kernel

Examples of org.apache.openjpa.kernel.Broker


        // ##### assertEquals (Class.class, o);
        CacheTestHelper.assertInCache(this, q, Boolean.FALSE);
    }

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

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


            return false;

        for (Iterator iter = ((AbstractBrokerFactory) JPAFacadeHelper
            .toBrokerFactory(emf)).getOpenBrokers().iterator();
            iter.hasNext(); ) {
            Broker b = (Broker) iter.next();
            if (b != null && !b.isClosed()) {
                EntityManager em = JPAFacadeHelper.toEntityManager(b);
                if (em.getTransaction().isActive())
                    em.getTransaction().rollback();
                em.close();
            }
View Full Code Here

            close(broker);
        }
    }

    public void testNonCacheableAccessPath() {
        Broker broker = JPAFacadeHelper.toBrokerFactory(factory).newBroker();
        try {
            org.apache.openjpa.kernel.Query q = broker.newQuery(
                JPQLParser.LANG_JPQL, "Select a FROM "
                + CacheObjectA.class.getSimpleName()
                + " a where a.relatedB.str = 'foo'");
            // "relatedB.str == 'foo'");
            q.setCandidateExtent(broker.newExtent(CacheObjectA.class, false));

            Collection c = (Collection) q.execute();
            iterate(c);

         // Query results are no longer dependent on cacheability of an entity.
View Full Code Here

            close(broker);
        }
    }

    public void testNonCacheableSubclasses1() {
        Broker broker = JPAFacadeHelper.toBrokerFactory(factory).newBroker();
        try {
            // a query on the CacheObjectA class includes an uncacheable
            // class; it should therefore not be cacheable.
            org.apache.openjpa.kernel.Query q = broker.newQuery(
                JPQLParser.LANG_JPQL, "Select a FROM "
                + CacheObjectA.class.getSimpleName() + " a");

            Collection c = (Collection) q.execute();
            iterate(c);
View Full Code Here

            close(broker);
        }
    }

    public void testNonCacheableSubclasses2() {
        Broker broker = JPAFacadeHelper.toBrokerFactory(factory).newBroker();
        try {
            // a query on the CacheObjectA extent configured without
            // subclasses does not include an uncacheable class; it should
            // therefore be cacheable.
            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));

            Collection c = (Collection) q.execute();
            iterate(c);

            assertInCache(q, Boolean.TRUE);
View Full Code Here

            // build up some queries to test

            // this one should be only on the superclass, since
            // CacheObjectF has a timeout.
            Broker broker = JPAFacadeHelper.toBroker(em);
            org.apache.openjpa.kernel.Query q1 = broker.newQuery(
                JPQLParser.LANG_JPQL, "select a from "
                + CacheObjectE.class.getSimpleName() + " a");
            q1.setCandidateExtent(broker.newExtent(CacheObjectE.class, false));
            iterate((Collection) q1.execute());
            assertInCache(q1, Boolean.TRUE);

            org.apache.openjpa.kernel.Query q2 = broker.newQuery(
                JPQLParser.LANG_JPQL, "Select a FROM "
                + CacheObjectF.class.getSimpleName() + " a");
            iterate((Collection) q2.execute());
            assertInCache(q2, Boolean.TRUE);
View Full Code Here

            em.persist(f);

            endTx(em);

            // build up some queries to test
            Broker broker = JPAFacadeHelper.toBroker(em);
            org.apache.openjpa.kernel.Query q1 = broker
                .newQuery(JPQLParser.LANG_JPQL, "SELECT a FROM CacheObjectE a");

            q1.setCandidateExtent(broker.newExtent(CacheObjectE.class, false));
            iterate((Collection) q1.execute());
            assertInCache(q1, Boolean.TRUE);

            org.apache.openjpa.kernel.Query q2 = broker
                .newQuery(JPQLParser.LANG_JPQL, "SELECT a FROM CacheObjectF a");
            iterate((Collection) q2.execute());
            assertInCache(q2, Boolean.TRUE);

            // if this run has a default timeout (set to 1 sec in the test
View Full Code Here

            assertTrue("Could not get queried objects into cache",
                attempts < 100);

            // build up a query that uses H in its access path...
            em = factory.createEntityManager();
            Broker broker = JPAFacadeHelper.toBroker(em);
            org.apache.openjpa.kernel.Query q = broker.newQuery(
                JPQLParser.LANG_JPQL, "Select a FROM "
                + CacheObjectJ.class.getSimpleName()
                + " a where a.str = 'h'");
            iterate((Collection) q.execute());
            assertInCache(q, Boolean.TRUE);
View Full Code Here

        CacheObjectE e = new CacheObjectE("e");
        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();)
            iter.next();

        assertEquals(1, c.size());
        assertInCache(q, Boolean.TRUE);

        ImplHelper.close(c);

        broker.close();
    }
View Full Code Here

                    .cast(factory)).getConfiguration()
                    .getMetaDataRepositoryInstance().getMetaData(a.getClass(),
                    null, false);
            FieldMetaData fmd = meta.getField("date");
            d = (Date) data.getData(fmd.getIndex());
            Broker broker = JPAFacadeHelper.toBroker(em1);
            OpenJPAStateManager sm = broker.getStateManager(a);
            assertTrue(sm == ((ProxyDate) a.getDate()).getOwner());
            assertEquals(Date.class, d.getClass());
        }
        finally {
            endEm(em0);
View Full Code Here

TOP

Related Classes of org.apache.openjpa.kernel.Broker

Copyright © 2018 www.massapicom. 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.