3 Replies Latest reply on May 16, 2007 3:21 PM by kasim

    Second level cache (ehcache) working?

    shakenbrain

      Has anyone been able to get ehcache working in a Seam application? I've enabled ehcache in my persistence unit:

      <property name="hibernate.cache.use_second_level_cache" value="true"/>
       <property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider"/>


      and enabled caching for one of my entities:

      @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
      public class Organization extends PersistentObject {
      ...
      }


      I created a basic ehcache.xml file as follows:

      <ehcache>
      
       <diskStore path="java.io.tmpdir"/>
      
       <defaultCache
       maxElementsInMemory="10000"
       eternal="false"
       timeToIdleSeconds="120"
       timeToLiveSeconds="120"
       overflowToDisk="true"
       diskPersistent="false"
       diskExpiryThreadIntervalSeconds="120"
       memoryStoreEvictionPolicy="LRU"
       />
      
      </ehcache>


      I put ehcache.xml into a jar file called ehcache.jar in server/default/lib so ehcache is able to find it. Where is this file really supposed to go? Does it really have to live there because that's where ehcache-1.2.3.jar is?

      After loading an entity in my Seam application I update it in underlying database using an external application. I would expect the entity to remain unchanged when viewing in it my Seam application because the object should be cached, but it's obviously being reloaded from the database.

      Any ideas?