hibernate - 尝试使用 Infinispan 作为 JPA/Hibernate 二级缓存提供程序,但没有成功

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

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

(持久性.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。

最佳答案

关于hibernate - 尝试使用 Infinispan 作为 JPA/Hibernate 二级缓存提供程序,但没有成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6776691/

相关文章:

java - 设计客户端-数据库-服务器

java - 如何解决线程 “main” javax.naming.NameNotFoundException : not bound?中的异常

jboss - org.apache.cxf.BusException : No DestinationFactory was found for the namespace http://schemas. xmlsoap.org/soap/http/

java - EhCache + hibernate

java - 具有大量并发事务的 Hibernate 二级缓存 ObjectNotFoundException

java - 为同一个 Hibernate 二级缓存区域映射两个 CacheConcurrencyStrategy

hibernate - 如果多列约束之一为空,则Hibernate `unique`约束不起作用

java - 将 NoSuchBeanDefinitionException 存储库引入服务

java - Spring Boot - 出现意外错误(类型=错误请求,状态=400)。缺少必需的请求正文

jboss5.x - 我想在同一台机器上同时运行 JBoss 4.2.3 和 JBoss 5.1