Hibernate找到了对集合的共享引用

Hibernate找到了对集合的共享引用,hibernate,Hibernate,编辑-我简化了这篇文章,用一组内容重现了这个问题 我已经将hibernate从4.3.11升级到5.2.8,现在得到一个共享引用异常。我读过的各种相关帖子似乎都没有帮助 我的数据库表是 这些表格用于表示“事物”和“事物所拥有的事物”。e、 g.个人拥有房屋、房屋拥有计算机、计算机拥有组件。将“主”的所有递归集等转换为其“资产”。这在HibernateV5之前工作得非常好 MasterAsset.hbm.xml如下 ... <many-to-one name="master" class=

编辑-我简化了这篇文章,用一组内容重现了这个问题

我已经将hibernate从4.3.11升级到5.2.8,现在得到一个共享引用异常。我读过的各种相关帖子似乎都没有帮助

我的数据库表是

这些表格用于表示“事物”和“事物所拥有的事物”。e、 g.个人拥有房屋、房屋拥有计算机、计算机拥有组件。将“主”的所有递归集等转换为其“资产”。这在HibernateV5之前工作得非常好

MasterAsset.hbm.xml如下

...
<many-to-one name="master" class="mypath.Master" fetch="select">
    <column name="MASTER_ID" not-null="true" />
</many-to-one>

<many-to-one name="asset" class="mypath.Master" fetch="select">
    <column name="MST_ASSET_ID" not-null="true" />
</many-to-one>
...

<set name="masterAssetLinkedToAsset" table="MASTER_ASSET" inverse="true" lazy="true" fetch="select">
    <key column="MASTER_ID" property-ref="asset"/>
    <one-to-many class="mypath.MasterAsset"/>
</set>
这给了我一个错误:

javax.persistence.RollbackException: Error while committing the transaction
    at org.hibernate.internal.ExceptionConverterImpl.convertCommitException(ExceptionConverterImpl.java:75)
    at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:71)
    at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:91)
    ... 
Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: Found shared references to a collection: mypath.domain.MasterAsset.masterAssetLinkedToAsset
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:147)
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155)
    at org.hibernate.internal.ExceptionConverterImpl.convertCommitException(ExceptionConverterImpl.java:56)
    ... 26 more
Caused by: org.hibernate.HibernateException: Found shared references to a collection: mypath.domain.MasterAsset.masterAssetLinkedToAsset
    at org.hibernate.engine.internal.Collections.processReachableCollection(Collections.java:182)
    at org.hibernate.event.internal.FlushVisitor.processCollection(FlushVisitor.java:42)
    at org.hibernate.event.internal.AbstractVisitor.processValue(AbstractVisitor.java:104)
creteria.list(MasterAsset)
javax.persistence.RollbackException: Error while committing the transaction
    at org.hibernate.internal.ExceptionConverterImpl.convertCommitException(ExceptionConverterImpl.java:75)
    at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:71)
    at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:91)
    ... 
Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: Found shared references to a collection: mypath.domain.MasterAsset.masterAssetLinkedToAsset
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:147)
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155)
    at org.hibernate.internal.ExceptionConverterImpl.convertCommitException(ExceptionConverterImpl.java:56)
    ... 26 more
Caused by: org.hibernate.HibernateException: Found shared references to a collection: mypath.domain.MasterAsset.masterAssetLinkedToAsset
    at org.hibernate.engine.internal.Collections.processReachableCollection(Collections.java:182)
    at org.hibernate.event.internal.FlushVisitor.processCollection(FlushVisitor.java:42)
    at org.hibernate.event.internal.AbstractVisitor.processValue(AbstractVisitor.java:104)