我想使用Infinispan来缓存重复调用的查询。
我按照这个教程来设置Hibernate:
Using Infinispan as JPA-Hibernate Second Level Cache Provider。
我遵循了每一步,虽然日志显示Infinispan被用作二级缓存并启用了查询缓存,但似乎没有缓存任何查询。
我还尝试了这个教程:Infinispan as Hibernate 2nd-Level Cache in JBoss AS 5.x,同样没有成功。
以下是我所做的配置摘录:
(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>我使用的是hibernate EAP5.1和JBoss -infinispan3.5.6-Final。
发布于 2011-07-22 16:14:58
交叉发布的http://community.jboss.org/thread/169801?tstart=0
https://stackoverflow.com/questions/6776691
复制相似问题