Found shared references to a collection org.hibernate.HibernateException

前端 未结 12 1319
一整个雨季
一整个雨季 2020-11-27 15:48

I got this error message:

error: Found shared references to a collection: Person.relatedPersons

When I tried to execute ad

12条回答
  •  爱一瞬间的悲伤
    2020-11-27 16:18

    I faced similar exception in my application. After looking into the stacktrace it was clear that exception was thrown within a FlushEntityEventListener class.

    In Hibernate 4.3.7 the MSLocalSessionFactory bean no longer supports the eventListeners property. Hence, one has to explicitly fetch the service registry from individual Hibernate session beans and then set the required custom event listeners.

    In the process of adding custom event listeners we need to make sure the corresponding default event listeners are removed from the respective Hibernate session.

    If the default event listener is not removed then the case arises of two event listeners registered against same event. In this case while iterating over these listeners, against first listeners any collections in the session will be flagged as reached and while processing the same collection against second listener would throw this Hibernate exception.

    So, make sure that when registering custom listeners corresponding default listeners are removed from registry.

提交回复
热议问题