Search in sources :

Example 1 with QueryCache

use of org.hibernate.cache.spi.QueryCache in project hibernate-orm by hibernate.

the class CacheImpl method close.

@Override
public void close() {
    for (EntityRegionAccessStrategy access : entityRegionAccessStrategyMap.values()) {
        access.getRegion().destroy();
    }
    for (CollectionRegionAccessStrategy access : collectionRegionAccessStrategyMap.values()) {
        access.getRegion().destroy();
    }
    if (settings.isQueryCacheEnabled()) {
        defaultQueryCache.destroy();
        for (QueryCache cache : queryCaches.values()) {
            cache.destroy();
        }
        updateTimestampsCache.destroy();
    }
    regionFactory.stop();
}
Also used : QueryCache(org.hibernate.cache.spi.QueryCache) StandardQueryCache(org.hibernate.cache.internal.StandardQueryCache) EntityRegionAccessStrategy(org.hibernate.cache.spi.access.EntityRegionAccessStrategy) CollectionRegionAccessStrategy(org.hibernate.cache.spi.access.CollectionRegionAccessStrategy)

Example 2 with QueryCache

use of org.hibernate.cache.spi.QueryCache in project hibernate-orm by hibernate.

the class CacheImpl method getQueryCache.

@Override
public QueryCache getQueryCache(String regionName) throws HibernateException {
    if (!settings.isQueryCacheEnabled()) {
        return null;
    }
    if (regionName == null) {
        return getDefaultQueryCache();
    }
    QueryCache queryCache = queryCaches.get(regionName);
    if (queryCache == null) {
        synchronized (queryCaches) {
            queryCache = queryCaches.get(regionName);
            if (queryCache == null) {
                final QueryResultsRegion region = regionFactory.buildQueryResultsRegion(qualifyRegionName(regionName), sessionFactory.getProperties());
                queryCache = settings.getQueryCacheFactory().buildQueryCache(region, this);
                queryCaches.put(regionName, queryCache);
            }
        }
    }
    return queryCache;
}
Also used : QueryCache(org.hibernate.cache.spi.QueryCache) StandardQueryCache(org.hibernate.cache.internal.StandardQueryCache) QueryResultsRegion(org.hibernate.cache.spi.QueryResultsRegion)

Aggregations

StandardQueryCache (org.hibernate.cache.internal.StandardQueryCache)2 QueryCache (org.hibernate.cache.spi.QueryCache)2 QueryResultsRegion (org.hibernate.cache.spi.QueryResultsRegion)1 CollectionRegionAccessStrategy (org.hibernate.cache.spi.access.CollectionRegionAccessStrategy)1 EntityRegionAccessStrategy (org.hibernate.cache.spi.access.EntityRegionAccessStrategy)1