0 Replies Latest reply on Jun 5, 2014 12:23 PM by sheriel

    How to set per Entity expiration.lifespan

    sheriel Newbie

      I have a java web application deployed on Jboss 6.1.0, that uses infinispan 5.2.6.Final. I'm trying to set a per Entity specific expiration.lifespan following this guide

      http://infinispan.org/docs/5.2.x/user_guide/user_guide.html#_advanced_configuration_2

      for my Entity bean named com.myenterprise.myproject.dal.ejb.entity.RefStatus.

      The guide states the following:

      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"/>

      So, I've added the following element to my persistence.xml, to reduce the lifespan to 10 milliseconds for test purposes, in order to fine tune it later:

      <property name="hibernate.cache.infinispan.com.myenterprise.myproject.dal.ejb.entity.RefStatus.expiration.lifespan" value= "10"/>


      The setting produces no effects and the lifespan remains the default.

      Do you know how I have to set the persistence.xml to successfully override the default expiration lifespan?

      Setting the

      <property name="hibernate.cache.infinispan.entity.expiration.lifespan" value= "10"/>

      it works, but it affects all entity caches, and it is not what I want.

      What follows is my application.xml file:

      <?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>
         
       

      Thank you very much.