Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2013-01-16 04:31:54 -0500
committerMartin Taal2013-01-16 04:31:54 -0500
commitbf75a59ef46c76a0ececee5adab103d044a22393 (patch)
treeb1ebb07890e2ba19804061d5c03b03bdf5715a65
parent0b0f6ab205b23d126a5aa50a3f269ed4b0ccd076 (diff)
downloadcdo-bf75a59ef46c76a0ececee5adab103d044a22393.tar.gz
cdo-bf75a59ef46c76a0ececee5adab103d044a22393.tar.xz
cdo-bf75a59ef46c76a0ececee5adab103d044a22393.zip
Fixes issue [398275] - [Hibernate] Map entries are not deleted using delete-orphan
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOOneToManyMapper.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOOneToManyMapper.java b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOOneToManyMapper.java
index 6a4b580d5a..f0fd1db54b 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOOneToManyMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOOneToManyMapper.java
@@ -10,9 +10,11 @@
*/
package org.eclipse.emf.cdo.server.hibernate.teneo;
+import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEReference;
import org.eclipse.emf.teneo.hibernate.hbannotation.HbCascadeType;
import org.eclipse.emf.teneo.hibernate.mapper.OneToManyMapper;
import org.eclipse.emf.teneo.simpledom.Element;
+import org.eclipse.emf.teneo.util.StoreUtil;
import java.util.List;
@@ -24,9 +26,27 @@ import java.util.List;
*/
public class CDOOneToManyMapper extends OneToManyMapper
{
+
+ private static ThreadLocal<Boolean> isMapMappedAsList = new ThreadLocal<Boolean>();
+
@Override
protected void addCascades(Element associationElement, List<HbCascadeType> cascades, boolean addDeleteOrphan)
{
- super.addCascades(associationElement, cascades, false);
+ super.addCascades(associationElement, cascades, isMapMappedAsList.get() ? addDeleteOrphan : false);
+ }
+
+ @Override
+ public void process(PAnnotatedEReference paReference)
+ {
+ // is a map and is not mapped as true map
+ isMapMappedAsList.set(StoreUtil.isMap(paReference.getModelEReference()) && !getHbmContext().isMapEMapAsTrueMap());
+ try
+ {
+ super.process(paReference);
+ }
+ finally
+ {
+ isMapMappedAsList.set(null);
+ }
}
}

Back to the top