Explanation of the second level cache code in Hibernate?

那年仲夏 提交于 2021-02-17 05:49:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!