Using Infinispan with JBoss EAP 5.1
helpermethod Jul 21, 2011 8:51 AMIn our current project, we would like to use Infinispan to cache repeatedly called queries.
In order to do so, we set up JPA/Hibernate according to this tutorial:
Following are some excerpts of the configuration 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" />{code}
<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>
According to the tutorial this should work but it doesn't. The logs show that Infinispan is used as a second level cache but queries are still not cached (actually, it seems that the cache doesn't get accessed at all).
We also followed this tutorial
https://docs.jboss.org/author/display/ISPN/Infinispan+as+Hibernate+2nd-Level+Cache+in+JBoss+AS+5.x
but also without success.
Thanks in advance,
Oliver