Hibernate在使用二级缓存时如何与数据库进行同步

How does Hibernate perform synchronization with the database when using the 2nd-level Cache

最近,我开始使用 Hibernate。

我只是想知道并消除我对 Hibernate 如何将二级缓存(例如 Ehcache)与数据库(隐式或显式)同步的疑问。

或者,我们是否必须始终使用 Hibernate API(例如 session.flush())来显式保持二级缓存与数据库同步?

第 2 级 CacheConcurrencyStrategy 定义缓存和数据库如何同步,因此: