简体   繁体   中英

How to set the Query cache?

I'm working on a Java Spring project. This project uses redisson-hibernate-53 cache and I'm able to cache entities by using this annotation @Cache ; however, I'm not sure how to set queries to be cached knowing that I use Spring JpaRepository and I write my queries as follows:

 @QueryHints(value = {@QueryHint(name = "org.hibernate.cacheable", value = "true")
                    , @QueryHint(name = "org.hibernate.cacheRegion", value = "FindByNameRegion")   })
 List<Employee> findByJobRole(String jobRole);

I added this property:

spring.jpa.properties.hibernate.cache.use_query_cache=true

But I think I'm missing some other configuration. Any help is appreciated!

The problem is the Redis server on Windows is not stable,however the exact configurations will work fine on other OS like linux.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM