Anurag Bhatia [http://community.jboss.org/people/ab_99] created the discussion

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

To view the discussion, visit: http://community.jboss.org/message/564483#564483

--------------------------------------------------------------
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 t...@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 
http://java.sun.com/xml/ns/persistence";
   xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance 
http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation=" http://java.sun.com/xml/ns/persistence 
http://java.sun.com/xml/ns/persistence  
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd 
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
[http://community.jboss.org/message/564483#564483]

Start a new discussion in EJB 3.0 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to