首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试将Infinispan用作JPA/Hibernate二级缓存提供程序,但未成功

尝试将Infinispan用作JPA/Hibernate二级缓存提供程序,但未成功
EN

Stack Overflow用户
提问于 2011-07-21 21:18:54
回答 1查看 2.4K关注 0票数 3

我想使用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)

代码语言:javascript
复制
<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)

代码语言:javascript
复制
<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。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-07-22 16:14:58

交叉发布的http://community.jboss.org/thread/169801?tstart=0

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6776691

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档