我收到此错误消息:
错误:找到对集合的共享引用:Person.latedPersons
当我尝试执行时addToRelatedPersons(anotherPerson)
:
person.addToRelatedPersons(anotherPerson);
anotherPerson.addToRelatedPersons(person);
anotherPerson.save();
person.save();
我的域名:
Person {
static hasMany = [relatedPersons:Person];
}
知道为什么会发生这种情况吗?
当您尝试保留多个共享实体实例时,Hibernate 会显示此错误same集合引用(即集合标识与集合相等性对比)。
注意,意思是一样的收藏,不是集合元素 - 换句话说relatedPersons
双方person
and anotherPerson
必须是相同的。也许您在加载实体后重置该集合?或者您已使用同一集合实例初始化了两个引用?
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)