Sample Code: Please see our sample application for Hibernate 2nd Level Cache Config.

If you are using Hibernate with Hazelcast as a second level cache provider, you can easily configure your LocalSessionFactoryBean to use a Hazelcast instance by passing Hazelcast instance name. That way, you can use the same HazelcastInstance as Hibernate L2 cache instance.

<bean id="sessionFactory" 
  <property name="dataSource" ref="dataSource"/>
  <property name="hibernateProperties">
          <prop key="hibernate.cache.region.factory_class">com.hazelcast.hibernate.HazelcastLocalCacheRegionFactory</prop>
          <prop key="hibernate.cache.hazelcast.instance_name">${}</prop>

Hibernate RegionFactory Classes

  • com.hazelcast.hibernate.HazelcastLocalCacheRegionFactory
  • com.hazelcast.hibernate.HazelcastCacheRegionFactory

Please refer to Hibernate Configuring RegionFactory for more information.