How to cache results of a Spring Data JPA query method without using query cache?
The reason the code you have is not working is that @Cache is not intended to work that way. If you want to cache the results of a query method execution, the easiest way is to use Spring’s caching abstraction. interface PromotionServiceXrefRepository extends PagingAndSortingRepository<PromotionServiceXref, Integer> { @Query(“…”) @Cacheable(“servicesByCustomerId”) Set<PromotionServiceXref> findByCustomerId(int customerId); @Override @CacheEvict(value = “servicesByCustomerId”, … Read more