Package org.apache.openjpa.datacache

Examples of org.apache.openjpa.datacache.QueryCache


     * results in AbstractQueryCache.onTypesChanges(TypesChangedEvent) being called.
     *
     * @throws Exception
     */
    public void testWriteLock() throws Exception {
        final QueryCache qc = emf.getConfiguration().getDataCacheManagerInstance().getSystemQueryCache();
        Thread t2 = new Thread() {
            public void run() {
                qc.writeLock();
                qc.writeUnlock();
            }
        };
        t2.start();
        t2.join(5000);
       
View Full Code Here


        Object[] args) {
        QueryKey qk = QueryKey.newInstance(query, args);
        Broker broker = query.getBroker();
        BrokerFactory factory = broker.getBrokerFactory();

        QueryCache qc = cacheManager(factory).getSystemQueryCache();
        if (inCache == Boolean.FALSE && qc.get(qk) != null) {
            tc.fail("query should not be in cache; was.");
        } else if (inCache == Boolean.TRUE || (inCache == null
            && qc.get(qk) != null)) {
            Object res = (args == null) ? query.execute()
                : query.execute(args);
            if (inCache == Boolean.TRUE &&
                !isCachedResult(res, inCache, query.getBroker()))
                tc.fail("query should be in cache; was not.");
View Full Code Here

    public void testBasicQuery() {
        basicQueries(factory.createEntityManager(), Boolean.FALSE, 3, 1);
        basicQueries(factory.createEntityManager(), Boolean.TRUE, 3, 1);

        // manually notify the cache of changes
        QueryCache cache = cacheManager(factory).getSystemQueryCache();

        // test to see if modifying B causes A's query cache to be flushed
        Set s = new HashSet();
        s.add(CacheObjectB.class);
        cache.onTypesChanged(new TypesChangedEvent(this, s));
        basicQueries(factory.createEntityManager(), Boolean.TRUE, 3, 1);

        // test to see if modifying A causes A's query cache to be flushed
        s.add(CacheObjectA.class);
        cache.onTypesChanged(new TypesChangedEvent(this, s));
        basicQueries(factory.createEntityManager(), Boolean.FALSE, 3, 1);

        // make sure that non-manual notification works
        EntityManager em = factory.createEntityManager();
        try {
View Full Code Here

        StoreQuery sq = newStoreQuery(language);
        if (sq == null || QueryLanguages.parserForLanguage(language) == null) {
            return sq;
        }

        QueryCache queryCache = _ctx.getConfiguration().getDataCacheManagerInstance().getSystemQueryCache();
        if (queryCache == null) {
            return sq;
        }
       
        return new QueryCacheStoreQuery(sq, queryCache);
View Full Code Here

                releaseConn = _connRetainMode != CONN_RETAIN_ALWAYS;
                if (rollback)
                    _store.rollback();
                else {
                    // and notify the query cache.  notify in one batch to reduce synch
                    QueryCache queryCache = getConfiguration().
                    getDataCacheManagerInstance().getSystemQueryCache();
                    if (queryCache != null) {
                        Collection<Class<?>> pers = getPersistedTypes();
                        Collection<Class<?>> del = getDeletedTypes();
                        Collection<Class<?>> up = getUpdatedTypes();
                        int size = pers.size() + del.size() + up.size();
                        if (size > 0) {
                            Collection<Class<?>> types = new ArrayList<Class<?>>(size);
                            types.addAll(pers);
                            types.addAll(del);
                            types.addAll(up);
                            queryCache.onTypesChanged(new TypesChangedEvent(this, types));
                        }
                    }
                    _store.commit();
                }
            } else {
View Full Code Here

    public void testBasicQuery() {
        basicQueries(factory.createEntityManager(), Boolean.FALSE, 3, 1);
        basicQueries(factory.createEntityManager(), Boolean.TRUE, 3, 1);

        // manually notify the cache of changes
        QueryCache cache = cacheManager(factory).getSystemQueryCache();

        // test to see if modifying B causes A's query cache to be flushed
        Set s = new HashSet();
        s.add(CacheObjectB.class);
        cache.onTypesChanged(new TypesChangedEvent(this, s));
        basicQueries(factory.createEntityManager(), Boolean.TRUE, 3, 1);

        // test to see if modifying A causes A's query cache to be flushed
        s.add(CacheObjectA.class);
        cache.onTypesChanged(new TypesChangedEvent(this, s));
        basicQueries(factory.createEntityManager(), Boolean.FALSE, 3, 1);

        // make sure that non-manual notification works
        EntityManager em = factory.createEntityManager();
        try {
View Full Code Here

TOP

Related Classes of org.apache.openjpa.datacache.QueryCache

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.