Search in sources :

Example 1 with QueryResultsCache

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

the class Loader method listUsingQueryCache.

private List listUsingQueryCache(final SharedSessionContractImplementor session, final QueryParameters queryParameters, final Set<Serializable> querySpaces, final Type[] resultTypes) {
    QueryResultsCache queryCache = factory.getCache().getQueryResultsCache(queryParameters.getCacheRegion());
    QueryKey key = generateQueryKey(session, queryParameters);
    if (querySpaces == null || querySpaces.size() == 0) {
        LOG.tracev("Unexpected querySpaces is {0}", (querySpaces == null ? querySpaces : "empty"));
    } else {
        LOG.tracev("querySpaces is {0}", querySpaces);
    }
    List result = getResultFromQueryCache(session, queryParameters, querySpaces, resultTypes, queryCache, key);
    if (result == null) {
        result = doList(session, queryParameters, key.getResultTransformer());
        putResultInQueryCache(session, queryParameters, resultTypes, queryCache, key, result);
    }
    ResultTransformer resolvedTransformer = resolveResultTransformer(queryParameters.getResultTransformer());
    if (resolvedTransformer != null) {
        result = (areResultSetRowsTransformedImmediately() ? key.getResultTransformer().retransformResults(result, getResultRowAliases(), queryParameters.getResultTransformer(), includeInResultRow()) : key.getResultTransformer().untransformToTuples(result));
    }
    return getResultList(result, queryParameters.getResultTransformer());
}
Also used : QueryKey(org.hibernate.cache.spi.QueryKey) CacheableResultTransformer(org.hibernate.transform.CacheableResultTransformer) ResultTransformer(org.hibernate.transform.ResultTransformer) List(java.util.List) ArrayList(java.util.ArrayList) QueryResultsCache(org.hibernate.cache.spi.QueryResultsCache)

Example 2 with QueryResultsCache

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

the class EnabledCaching method evictQueryRegion.

@Override
public void evictQueryRegion(String regionName) {
    final QueryResultsCache cache = getQueryResultsCache(regionName);
    if (cache == null) {
        return;
    }
    evictQueryResultRegion(cache);
}
Also used : QueryResultsCache(org.hibernate.cache.spi.QueryResultsCache)

Example 3 with QueryResultsCache

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

the class StatisticsImpl method getQueryRegionStatistics.

@Override
public CacheRegionStatisticsImpl getQueryRegionStatistics(String regionName) {
    final CacheRegionStatisticsImpl existing = l2CacheStatsMap.get(regionName);
    if (existing != null) {
        return existing;
    }
    if (sessionFactory == null) {
        return null;
    }
    final QueryResultsCache regionAccess = sessionFactory.getCache().getQueryResultsCacheStrictly(regionName);
    if (regionAccess == null) {
        return null;
    }
    return l2CacheStatsMap.computeIfAbsent(regionName, s -> new CacheRegionStatisticsImpl(regionAccess.getRegion()));
}
Also used : QueryResultsCache(org.hibernate.cache.spi.QueryResultsCache)

Aggregations

QueryResultsCache (org.hibernate.cache.spi.QueryResultsCache)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 QueryKey (org.hibernate.cache.spi.QueryKey)1 CacheableResultTransformer (org.hibernate.transform.CacheableResultTransformer)1 ResultTransformer (org.hibernate.transform.ResultTransformer)1