public class HibernateQueryResultsRegion extends HibernateGeneralDataRegion implements org.hibernate.cache.spi.QueryResultsRegion
QueryResultsRegion. This region is used to store query results.
Query results caching can be enabled in the Hibernate configuration file:
<hibernate-configuration>
<!-- Enable L2 cache. -->
<property name="cache.use_second_level_cache">true</property>
<!-- Enable query cache. -->
<property name="cache.use_second_level_cache">true</property>
<!-- Use Ignite as L2 cache provider. -->
<property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
<!-- Specify entity. -->
<mapping class="com.example.Entity"/>
<!-- Enable L2 cache with nonstrict-read-write access strategy for entity. -->
<class-cache class="com.example.Entity" usage="nonstrict-read-write"/>
</hibernate-configuration>
By default queries are not cached even after enabling query caching, to enable results caching for a particular
query, call Query.setCacheable(boolean):
Session ses = getSession();
Query qry = ses.createQuery("...");
qry.setCacheable(true); // Enable L2 cache for query.
Note: the query cache does not cache the state of the actual entities in the cache, it caches only identifier
values. For this reason, the query cache should always be used in conjunction with
the second-level cache for those entities expected to be cached as part of a query result cachecache, factory, ignite| Constructor and Description |
|---|
HibernateQueryResultsRegion(HibernateRegionFactory factory,
String name,
Ignite ignite,
org.apache.ignite.internal.processors.cache.IgniteInternalCache<Object,Object> cache) |
evict, evictAll, get, putcontains, destroy, getElementCountInMemory, getElementCountOnDisk, getName, getSizeInMemory, getTimeout, nextTimestamp, toMapclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic HibernateQueryResultsRegion(HibernateRegionFactory factory, String name, Ignite ignite, org.apache.ignite.internal.processors.cache.IgniteInternalCache<Object,Object> cache)
factory - Region factory.name - Region name.ignite - Grid.cache - Region cache.
Follow @ApacheIgnite
Ignite Fabric : ver. 1.5.11 Release Date : April 8 2016