如何在Spring Boot Data JPA中忽略/跳过@Cacheable的空列表或空列表?

时间:2018-12-11 16:43:28

标签: spring-boot caching spring-data-jpa

我正在尝试在Spring Boot应用程序中添加缓存。

以下是存储库方法:

@Cacheable(value = "booksByCategory", key = "#p0.categoryId", unless = "#result == null or #result.size()==0")
@EntityGraph(attributePaths = { "category" })
List<Book> findAllByCategoryId(Category category);

当List为EMPTY时,我不想缓存。 我在下面添加了:

unless = "#result == null or #result.size()==0"" 

,但不起作用。 如何在缓存时忽略/跳过空列表或空列表?

0 个答案:

没有答案
相关问题