JBoss Community

EJB3 and Hibernate Second Level Cache InvalidationEJB3 and Hibernate Second Level Cache Invalidation

created by Anurag Bhatia in EJB 3.0 - View the full discussion

I am using the hibernate second level cache for  my ejb3 entity beans for entity caching as well as query caching. Does  anyone have any idea on how to invalidate the hibernate second level  cache?
I tried to use the evictXXXX() methods in the sessionfactory but had no success. There is nothing there in the EntityPersisters or the CollecitonPersisters.

 

My entities are marked with the@Cache (usage=CacheConcurrencyStrategy.TRANSACTIONAL) annotation

 

The queries are used as follows -

 

 

      Query query = entityManager.createQuery(query String.........);
      query.setParameter(DATEPARAM, date);
      query.setHint("org.hibernate.cacheable", true);
      return query.getResultList();

 

persitence.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_1_0.xsd"
   version="1.0">
       <persistence-unit name="test">
          <jta-data-source>java:com/test/datasources/DataSource</jta-data-source>
          <properties>
            <property name="hibernate.cache.use_second_level_cache" value="true"/>
            <property name="hibernate.cache.use_query_cache" value="true"/>
            <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
            <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.jbc2.JndiMultiplexedJBossCacheRegionFactory"/>
            <property name="hibernate.cache.region.jbc2.cachefactory" value="java:CacheManager"/>
            <property name="hibernate.cache.region.jbc2.cfg.entity" value="mvcc-entity"/>
            <property name="hibernate.cache.region.jbc2.cfg.collection" value="mvcc-entity"/>
            <property name="hibernate.cache.region.jbc2.cfg.query" value="local-query"/>
            <property name="hibernate.cache.region_prefix" value="tempdb"/>
            <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
            <property name="hibernate.generate_statistics" value="true"/>
            <property name="hibernate.show_sql" value="true"/>
          </properties>
       </persistence-unit>
</persistence>

Reply to this message by going to Community

Start a new discussion in EJB 3.0 at Community