Configure Infinispan as second level cache in Hibernate

1.4k views Asked by At

I am trying to configure infinispan for caching in hibernate. Please can someone provide me with the steps that i need to follow and the configurations that i need to add in the infinispan-cache.xml file

1

There are 1 answers

1
Vlad Mihalcea On

First of all you need to add the following Hibernate properties:

<property name="hibernate.cache.use_second_level_cache" value="true" />    
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.JndiInfinispanRegionFactory" />
<property name="hibernate.cache.infinispan.cachemanager" value="java:CacheManager" />

Then you need to set the Entity cache selection policy:

<property name="javax.persistence.sharedCache.mode" value="ENABLE_SELECTIVE"/>

Only the entities annotated with @javax.persistence.Cacheable would be stored in the second-level cache.