2011-07-21 30 views
3

我想用Infinispan的緩存反覆調用查詢。嘗試使用Infinispan的作爲JPA/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> 

我使用JBoss EAP 5.1和hibernate-infinispan 3.5.6-Final。

+2

您是否嘗試過使用編程方式聲明查詢緩存?即query.setCacheable(真) 你怎麼知道查詢緩存不工作?你在檢查什麼? –

回答

相關問題