How to cache results of a Spring Data JPA query method without using query cache?

后端 未结 3 1307
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-12 20:00

I have a Spring Boot app with Spring Data JPA (hibernate backend) repository classes. I\'ve added a couple custom finder methods, some with specific @Query anno

3条回答
  •  天命终不由人
    2020-12-12 20:13

    You need to be aware that by giving up on the Hibernate QueryCache your are responsible for invalidating the queries that become stale when saving, updating, deleting entities that influenced the query result(what Oliver is doing by setting CacheEvict on save) - which I think can be a pain- or at least you need to take into account and ignore it if it's not really a problem for your scenario.

提交回复
热议问题