bug #6687

Updated by Andreas Kohlbecker over 3 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(
at org.hibernate.event.internal.MergeContext.put(
at org.hibernate.event.internal.DefaultMergeEventListener.entityIsDetached(
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(
at org.hibernate.internal.SessionImpl.fireMerge(
at org.hibernate.internal.SessionImpl.merge(
at org.hibernate.engine.spi.CascadingActions$6.cascade(

This problem is a known issue of hibernate: [Hibernate ORMHHH-9106 - Multiple representations of the same entity cannot be merged using cascade=merge](

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

<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.


Add picture from clipboard (Maximum size: 40 MB)