【问题标题】:Trying to use Infinispan as a JPA/Hibernate second level cache provider, without success尝试使用 Infinispan 作为 JPA/Hibernate 二级缓存提供程序,但没有成功
【发布时间】:2011-07-21 13:18:53
【问题描述】:

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

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

【问题讨论】:

  • 您是否尝试过声明查询可缓存的编程方式?即 query.setCacheable(true) 你怎么知道查询缓存不起作用?你具体检查什么?

标签: hibernate jboss5.x second-level-cache infinispan


【解决方案1】:
猜你喜欢
  • 2016-05-27
  • 2013-09-05
  • 2014-05-10
  • 1970-01-01
  • 2023-03-03
  • 2015-09-07
  • 2015-12-31
  • 2012-02-04
  • 1970-01-01
相关资源
最近更新 更多