Deepak
Deepak

Reputation: 81

Configure Infinispan as second level cache in Hibernate

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

Upvotes: 2

Views: 1658

Answers (1)

Vlad Mihalcea
Vlad Mihalcea

Reputation: 154130

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.

Upvotes: 1

Related Questions