java – Infinispan – 按实体设置expiration.lifespan
作者:互联网
我在Jboss 6.1.0上部署了一个java Web应用程序,它使用infinispan 5.2.6.Final.
我正在尝试按照本指南设置每个实体的特定expiration.lifespan
http://infinispan.org/docs/5.2.x/user_guide/user_guide.html#_advanced_configuration_2
对于我的实体bean com.myenterprise.myproject.dal.ejb.entity.RefStatus.
该指南说明如下:
You can also override eviction/expiration settings on a per entity/collection
type basis in such way that the overriden settings only afftect that particular
entity (i.e. com.acme.Person) or collection type (i.e. com.acme.Person.addresses).
For example:
<property name="hibernate.cache.infinispan.com.acme.Person.expiration.lifespan" value= "65000"/>
所以,我已经将以下元素添加到我的persistence.xml中,为了测试目的,将生命周期缩短到10毫秒,以便稍后进行微调:
<property name="hibernate.cache.infinispan.com.myenterprise.myproject.dal.ejb.entity.RefStatus.expiration.lifespan" value= "10"/>
该设置不产生任何效果,寿命仍然是默认值.
你知道我如何设置persistence.xml以成功覆盖默认的到期寿命吗?
设置
<property name="hibernate.cache.infinispan.entity.expiration.lifespan" value= "10"/>
它工作,但它影响所有实体缓存,它不是我想要的.
以下是我的application.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
<persistence-unit name="myProject_dal_PU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/myProject-DataSource</jta-data-source>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<properties>
<property name="hibernate.archive.autodetection" value="class" />
<property name="hibernate.bytecode.use_reflection_optimizer" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.cache.use_second_level_cache" value="true" />
<property name="hibernate.cache.use_minimal_puts" value="true" />
<property name="hibernate.cache.use_query_cache" value="true" />
<property name="hibernate.cache.infinispan.com.myenterprise.myproject.dal.ejb.entity.RefStatus.expiration.lifespan" value= "10"/>
</properties>
</persistence-unit>
</persistence>
谢谢.
解决方法:
如果您在应用程序服务器中运行,则除了实体名称之外,还必须提供部署名称和单元.因此,所有这些过期属性都需要添加前缀:hibernate.cache.infinispan.< warname>.< unitname>.<实体的FQN> …
在您的情况下,我不知道您的部署的名称,但是您提到的单位和FQN,如下所示:
hibernate.cache.infinispan< warname> .myProject_dal_PU.com.myenterprise.myproject.dal.ejb.entity.RefStatus.expiration.lifespan
标签:jboss6-x,persistence-xml,infinispan,java,caching 来源: https://codeday.me/bug/20190830/1770390.html