Spring Boot + JPA2 + Hibernate - enable second level cache -


i'm using spring boot 1.2.5 jpa2 annotate entities (and hibernate underlaying jpa implementation).

i wanted use second level cache in setup, entities annotated @javax.persistence.cacheable

i added following in application.properties:

spring.jpa.properties.hibernate.cache.use_second_level_cache=true spring.jpa.properties.hibernate.cache.use_query_cache=true spring.jpa.properties.hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.ehcacheregionfactory 

during bootup hibernate complained lack of ehcacheregionfactory added pom:

<dependency>     <groupid>org.hibernate</groupid>     <artifactid>hibernate-ehcache</artifactid> </dependency> 

but still queries entitymanager.find(clazz.class, pk) firing db query instead of using cached data.

any idea missing?

well after more digging here's missing in application.properties:

spring.jpa.properties.javax.persistence.sharedcache.mode=all 

hope helps :)


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -