为什么我看到CACHE错过了updateTimestampScache?

问题描述 投票:0回答:1
there是我的一个存储库类之一和自定义查找器方法的一个示例:

public interface PromotionServiceXrefRepository extends PagingAndSortingRepository<PromotionServiceXref, Integer> { @Query("SELECT psx FROM Customer c " + "JOIN c.customerProductPromotions cpp " + "JOIN cpp.productPromotion pp " + "JOIN pp.promotion p JOIN p.promotionServiceXrefs psx " + "WHERE c.sonosId = ?1") @QueryHints(@QueryHint(name = "org.hibernate.cacheable", value = "true")) @Cache(usage = CacheConcurrencyStrategy.READ_ONLY, region = "promotionServiceXrefByCustomerId") Set<PromotionServiceXref> findByCustomerId(int customerId); }
    

我的猜测是,除非对表进行修改(更新,插入,删除),否则Hibernate不会将时间戳放入“默认上的更高 - timestamps-grigion”中。因此,最初,该区域是空的,只读的表格永远不会时间戳。反过来,这意味着查询缓存将无法与这些实体一起使用,因为它无法判断该表是否已更新(没有时间戳)。
理论上,您可以尝试在启动时使用类似的东西预先填充该地区:
spring hibernate ehcache spring-boot spring-data-jpa
1个回答
0
投票

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.