Project

General

Profile

bug #6687

Updated by Andreas Kohlbecker over 2 years ago

The `eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter<DTO extends CdmBase, V extends ApplicationView<?>>` class uses short running sessions. Modified entities must thus be merged into the new Session before they can be saved.
In some cases however the merge fails with an IllegalStateException like the one that is shown below. The below exception was thrown after while merging a BotanicalName instance whereas the Person (id:10) is at the same time the *combinationAuthor* and the author of the associated *nomenclaturalReference* :

~~~
Caused by: java.lang.IllegalStateException: Multiple representations of the same entity [eu.etaxonomy.cdm.model.agent.Person#10] are being merged. Detached: [Cheng-Long Shaw]; Managed: [Cheng-Long Shaw]
at org.hibernate.event.internal.EntityCopyNotAllowedObserver.entityCopyDetected(EntityCopyNotAllowedObserver.java:37)
at org.hibernate.event.internal.MergeContext.put(MergeContext.java:245)
at org.hibernate.event.internal.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:304)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:170)
at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:850)
at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:832)
at org.hibernate.engine.spi.CascadingActions$6.cascade(CascadingActions.java:260)
~~~

This problem is a known issue of hibernate: [Hibernate ORMHHH-9106 - Multiple representations of the same entity cannot be merged using cascade=merge](https://hibernate.atlassian.net/browse/HHH-9106)

Since Hibernate 4.3.6 there is a hibernate property to work around this problem:

~~~xml
<prop key="hibernate.event.merge.entity_copy_observer">allow</prop>
~~~

When using `hibernate.event.merge.entity_copy_observer=allow` you `hibernate.event.merge.entity_copy_observer=allow`mus must be aware of the risks and possible side effects, please refer to the patagraphs **RISKS OF MERGING ENTITY COPIES** and **RECOMMENDATIONS** in the above linked issue.

Back

Add picture from clipboard (Maximum size: 40 MB)