java - hibernate中二级缓存中缓存了哪些类

标签 java hibernate orm second-level-cache

有没有办法让我找出哪些类(即哪些不同类型的实例)被缓存在hibernate二级缓存中。

最佳答案

二级缓存不缓存实体的实例,它缓存实体的“脱水”版本。这在blog post中有很好的解释。 :

The 2nd level cache

The hibernate cache does not store instances of an entity - instead Hibernate uses something called dehydrated state. A dehydrated state can be thought of as a deserialized entity where the dehydrated state is like an array of strings, integers etc and the id of the entity is the pointer to the dehydrated entity. Conceptually you can think of it as a Map which contains the id as key and an array as value. Or something like below for a cache region:

{ id -> { atribute1, attribute2, attribute3 } }
{ 1 -> { "a name", 20, null } }
{ 2 -> { "another name", 30, 4 } }

If the entity holds a collection of other entities then the other entity also needs to be cached. In this case it could look something like:

{ id -> { atribute1, attribute2, attribute3, Set{item1..n} } }
{ 1 -> { "a name", 20, null, {1,2,5} } }
{ 2 -> { "another name", 30, 4, {4,8} } }

根据您使用的二级缓存提供程序,您可能会获得一些控制台来监视/浏览缓存,但您仍然看不到“实例”。

资源

关于java - hibernate中二级缓存中缓存了哪些类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3715301/

相关文章:

java - 如何对可用性检查进行编程并在 Outlook 中创建新 session ?

java - 限定名称和字段访问表达式有什么区别?

java - Canvas 在特定设备上不可见(One X)

java - 无法部署 WAR : ClassNotFoundException - What am I still missing?

forms - .net Windows 窗体应用程序的自动 CRUD 窗体生成

java - Hibernate 与连接表的映射异常

java - org.hibernate.HibernateException : Error while indexing in Hibernate Search (before transaction completion)

java - hibernate 异常 : proxy handle is no longer valid after database violation error

mysql - 对于支持事务的 Node.js 和 MariaDB,我应该使用哪种 ORM?

coldfusion - 使用 ColdFusion 框架