hibernate-springcache

Hibernate cache implementation that backs to the Spring Cache abstraction

Hibernate SpringCache

DevOps By Rultor.com Build Status Maven Central Reference Status Dependency Status Javadoc

Hibernate SpringCache is a Hibernate cache implementation that backs to the Spring Cache abstraction. In other words, setup caching once in Spring then use it from Spring and Hibernate so configuration isn’t duplicated.

This project has been submitted to Hibernate for inclusion: https://github.com/hibernate/hibernate-orm/pull/1639

Quick Start

  • Minimum requirements — You’ll need Java 1.8+, Hibernate 5.2.6+, and Spring 4.3+. Spring Boot 1.4+ is optional.
  • Download — Depend on this libary using, for example, Maven: xml <dependency> <groupId>com.integralblue</groupId> <artifactId>hibernate-springcache</artifactId> <version>[INSERT VERSION HERE]</version> <type>jar</type> </dependency>
  • In application.properties, add:
    • spring.jpa.properties.hibernate.cache.region.factory_class=com.integralblue.hibernate.cache.springcache.SpringCacheRegionFactory
    • To enable the query cache, add: spring.jpa.properties.hibernate.cache.use_query_cache=true See the Hibernate query caching documentation for more information.
    • To enable the second level cache, add: spring.jpa.properties.hibernate.cache.use_second_level_cache=true spring.jpa.properties.javax.persistence.sharedCache.mode=ENABLE_SELECTIVE See the Hibernate query caching documentation for more information.
  • If using Spring Boot, that’s it - com.integralblue.hibernate.cache.springcache.SpringCacheRegionFactoryAutoConfigure will take care of the rest.
  • If not not using Spring boot, the com.integralblue.hibernate.cache.springcache.SpringCacheRegionFactoryBeanPostProcessor bean post processor must be registered (add it as a bean using Spring Java or XML configuration).

Related Repositories

hibernate-springcache

hibernate-springcache

Hibernate cache implementation that backs to the Spring Cache abstraction ...