I would like to use Infinispan to cache repeatedly called queries.
I followed this tutorial to set up Hibernate for this:
Using Infinispan as JPA-Hibernate Second Level Cache Provider.
I followed every step, and while the log shows that Infinispan is used as a second-level cache and query caching enabled, no queries seem to be cached.
I also tried out开发者_Go百科 this tutorial: Infinispan as Hibernate 2nd-Level Cache in JBoss AS 5.x, also without success.
Here are excerpts of the configuration I've done:
(orm.xml)
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
version="1.0">
<named-query name="retrievePolicySet">
<query>from PSTRepresentationType p where p.realm=? AND p.policySetType.policySetId=?</query>
<hint name="org.hibernate.cacheable" value="true" />
</named-query>
<named-query name="retrievePolicySetList">
<query>from PSTRepresentationType p where p.realm=?</query>
<hint name="org.hibernate.cacheable" value="true" />
</named-query>
</entity-mappings>
(persistence.xml)
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.cache.use_second_level_cache" value="true" />
<!-- Enables the query cache. Individual queries still have to be set cachable. -->
<property name="hibernate.cache.use_query_cache" value="true" />
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.InfinispanRegionFactory" />
<property name="hibernate.cache.infinispan.statistics" value="true" />
</properties>
I'm using JBoss EAP 5.1 and hibernate-infinispan 3.5.6-Final.
Cross posted http://community.jboss.org/thread/169801?tstart=0
精彩评论