问题
I have the two following entities
@Cachable
class Book{
...
@ManyToOne
Publisher publisher;
}
@Cachable{
class Publisher{
...
}
I have the following test code,
@Test
public void test{
stats = sessionFactory.getStatstics();
...
Book book = session.byId(Book.class).load(1);
Book book2 = session.byId(Book.class).load(1);
assertEquals(stats.getSecondLevelCacheHitCount,0);
assertEquals(stats.getSecondLevelCacheMissCount,1);
assertEquals(stats.getSecondLevelCachePutCount,2);
}
Why the cache miss count is 1 and cache put count is 2? Shouldn't cache miss count be 2, if cache put count is 2?
来源:https://stackoverflow.com/questions/64320669/explanation-of-the-second-level-cache-code-in-hibernate