Pop up and start JPA2 hibernate – enable L2 cache

I use spring boot 1.2 5 and JPA 2 annotation entities (and Hibernate as the underlying JPA Implementation)

I want to use L2 cache in this setting, so the entity uses @ javax persistence. Cacheable annotation

I'm still in application The following content has been added to 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 startup, hibernate complained about the lack of ehcacheregionfactory, so I also added it to POM:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-ehcache</artifactId>
</dependency>

But, like entitymanager Queries such as find (clazz. Class, PK) still trigger database queries instead of using cached data

Any idea what is missing?

Solution

So in some more mining, here is my application Missing in properties:

spring.jpa.properties.javax.persistence.sharedCache.mode=ALL

Hope it helps someone:)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>