且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

找到对集合 org.hibernate.HibernateException 的共享引用

更新时间:2023-09-15 17:44:04

当您尝试保留多个共享相同集合引用(即集合标识相反的实体实例)时,Hibernate 会显示此错误与集合相等).

Hibernate shows this error when you attempt to persist more than one entity instance sharing the same collection reference (i.e. the collection identity in contrast with collection equality).

请注意,这意味着相同的 collection,而不是集合元素 - 换句话说,personanotherPerson 上的 relatedPersons代码> 必须相同.也许您正在加载实体后重置该集合?或者你已经用同一个集合实例初始化了两个引用?

Note that it means the same collection, not collection element - in other words relatedPersons on both person and anotherPerson must be the same. Perhaps you're resetting that collection after entities are loaded? Or you've initialized both references with the same collection instance?