1 Reply Latest reply on Sep 13, 2016 6:02 AM by rvansa

    Infinispan 2nd level JPA cache using hibernate and H2 DB

    prasanna1947

      I am trying to write a sample application  to make use of a JPA 2nd level cache, but Cache Query it is not working as expected.

      I have Employee object which is cache-able, now i have a test case (JpaCachingTest.shouldCacheQuery)  to test the query cache. This test case first creates 2 employee objects and calling persist  on EntityManager, now these 2 employee objects are available in 2nd level cache (EntityManagerFactory). Now i cleared the cache, and try to find one of the employee object using another session (EntityManager2.find) , and i am able to find the object (sql query fired by hibernate to fetch the row) but this object is not loaded into the 2nd level cache. In order to get this object i need to explicitly call em2.refresh(emp).

       

      I dont know if it is a bug with inifinispan (org.hibernate.cache.infinispan.InfinispanRegionFactory) or if i am missing any configuration. The same working with ehcache or eclipselink. Here i am uploading my project ( please have a look at infinispan.xml, persitance.xml and JpaCachingTest).