我打算在 hibernate 中使用这个 StatelessSession 接口(interface)。但是不知道解释here有什么数据混叠效果
最佳答案
考虑像这样的数据
table parent
id | name
---------
1 | 'foo'
table child
id | parent_id
--------------
1 | 1
2 | 1
和一个查询
session.query("from child").list();
那么以下将失败
StatelessSession session
但不适用于 Session session
childs.get(0).getParent().setName("bar");
assertEqual("bar", childs.get(1).getParent().getName());
更新:
StatelessSession 不会“记住”它加载的对象,因此在脱水第二个 child 时,它不知道它已经创建了它所引用的父对象,并将创建另一个具有相同值但引用不同的父对象。
关于hibernate - 什么是 hibernate 中的数据混叠效应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13524097/