Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2010-02-19 08:13:30 +0000
committerMartin Taal2010-02-19 08:13:30 +0000
commit35e4d303a48b1754cb8786555fa6cf534e482f72 (patch)
tree81ce6116767b6ea2e96ab20f10ebf056d553d98a /plugins/org.eclipse.emf.cdo.server.hibernate.teneo
parentb270e15246d69113f0f677c980354dd0a6be551b (diff)
downloadcdo-35e4d303a48b1754cb8786555fa6cf534e482f72.tar.gz
cdo-35e4d303a48b1754cb8786555fa6cf534e482f72.tar.xz
cdo-35e4d303a48b1754cb8786555fa6cf534e482f72.zip
[300621] [Hibernate] CDO_Package_Unit type has a field which is too long for Derby
[300645] [Hibernate] Ensure that the Teneo extension mechanism works in combination with CDO [300659] [Hibernate] Handle unknown edatatypes as a string [300695] CDOENumStringType.nullSafeGet require identical name and literal for EEnum [283237] [Hibernate] Externalize strings and NON-NLS where appropriate [300256]: [Hibernate] several changes: properties can be set in config file
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.hibernate.teneo')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/META-INF/MANIFEST.MF5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProvider.java69
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProviderFactory.java45
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOBasicMapper.java (renamed from plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOBasicMapper.java)111
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOEDataTypeAnnotator.java33
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOEFeatureAnnotator.java (renamed from plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOEFeatureAnnotator.java)105
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOEntityMapper.java (renamed from plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOEntityMapper.java)149
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOHelper.java97
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOManyAttributeMapper.java (renamed from plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOManyAttributeMapper.java)67
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOMappingContext.java (renamed from plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOMappingContext.java)309
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOMappingGenerator.java121
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOXmlPersistenceContentHandler.java (renamed from plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOXmlPersistenceContentHandler.java)193
12 files changed, 716 insertions, 588 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/META-INF/MANIFEST.MF
index 68452fc1cd..f1bc4a60ce 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/META-INF/MANIFEST.MF
@@ -6,6 +6,7 @@ Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Eclipse-BuddyPolicy: registered
Require-Bundle: org.eclipse.emf.ecore.xmi;bundle-version="[2.4.0,3.0.0)",
org.eclipse.emf.cdo;bundle-version="3.0.0",
org.eclipse.emf.cdo.server;bundle-version="3.0.0",
@@ -17,9 +18,9 @@ Import-Package: org.eclipse.emf.teneo;version="[1.1.2,2.0.0)",
org.eclipse.emf.teneo.annotations.pannotation;version="[1.1.2,2.0.0)",
org.eclipse.emf.teneo.annotations.xml;version="[1.1.2,2.0.0)",
org.eclipse.emf.teneo.extension;version="[1.1.2,2.0.0)",
+ org.eclipse.emf.teneo.hibernate.annotations;version="[1.1.2,2.0.0)",
org.eclipse.emf.teneo.hibernate.mapper;version="[1.1.2,2.0.0)",
- org.eclipse.emf.teneo.simpledom;version="[1.1.2,2.0.0)",
- org.hibernate.cfg;version="[3.3.2,4.0.0)"
+ org.eclipse.emf.teneo.simpledom;version="[1.1.2,2.0.0)"
Export-Package: org.eclipse.emf.cdo.server.hibernate.internal.teneo;version="3.0.0";x-friends:="org.eclipse.emf.cdo.tests.hibernate",
org.eclipse.emf.cdo.server.hibernate.internal.teneo.bundle;version="3.0.0";x-friends:="org.eclipse.emf.cdo.tests.hibernate",
org.eclipse.emf.cdo.server.hibernate.teneo;version="3.0.0"
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProvider.java b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProvider.java
index 70dedac35d..e6adea55f9 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProvider.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProvider.java
@@ -13,11 +13,10 @@ package org.eclipse.emf.cdo.server.hibernate.internal.teneo;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
import org.eclipse.emf.cdo.server.hibernate.internal.teneo.bundle.OM;
-import org.eclipse.emf.cdo.server.hibernate.teneo.CDOHelper;
+import org.eclipse.emf.cdo.server.hibernate.teneo.CDOMappingGenerator;
import org.eclipse.emf.cdo.server.internal.hibernate.CDOHibernateConstants;
import org.eclipse.emf.cdo.server.internal.hibernate.HibernateMappingProvider;
import org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore;
-import org.eclipse.emf.cdo.server.internal.hibernate.HibernateUtil;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -28,10 +27,10 @@ import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.teneo.PackageRegistryProvider;
import org.eclipse.emf.teneo.PersistenceOptions;
-import org.eclipse.emf.teneo.extension.ExtensionManager;
-import org.eclipse.emf.teneo.extension.ExtensionManagerFactory;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
/**
@@ -39,20 +38,23 @@ import java.util.Properties;
*
* @author Martin Taal
* @author Eike Stepper
+ * @since 3.0
*/
public class TeneoHibernateMappingProvider extends HibernateMappingProvider
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, TeneoHibernateMappingProvider.class);
- private ExtensionManager extensionManager = ExtensionManagerFactory.getInstance().create();
+ private Map<String, String> extensions = new HashMap<String, String>();
+
+ private Properties mappingProviderProperties = new Properties();
public TeneoHibernateMappingProvider()
{
}
- public ExtensionManager getExtensionManager()
+ public void putExtension(String extensionClassName, String extendingClassName)
{
- return extensionManager;
+ extensions.put(extensionClassName, extendingClassName);
}
@Override
@@ -61,23 +63,16 @@ public class TeneoHibernateMappingProvider extends HibernateMappingProvider
return (HibernateStore)super.getHibernateStore();
}
- @SuppressWarnings("restriction")
- public void addMapping(org.hibernate.cfg.Configuration configuration)
+ public String getMapping()
{
final String mapping = generateMapping();
if (TRACER.isEnabled())
{
- TRACER.trace("Generated hibernate mapping:");
+ TRACER.trace("Generated hibernate mapping:"); //$NON-NLS-1$
TRACER.trace(mapping);
}
- System.err.println(mapping);
-
- configuration.addXML(mapping);
- if (TRACER.isEnabled())
- {
- TRACER.trace("Added mapping to configuration");
- }
+ return mapping;
}
// the passed modelObjects collection is defined as a collection of Objects
@@ -86,10 +81,17 @@ public class TeneoHibernateMappingProvider extends HibernateMappingProvider
{
if (TRACER.isEnabled())
{
- TRACER.trace("Generating Hibernate Mapping");
+ TRACER.trace("Generating Hibernate Mapping"); //$NON-NLS-1$
}
- final Properties properties = HibernateUtil.getInstance().getPropertiesFromStore(getHibernateStore());
+ final Properties storeProperties = getHibernateStore().getProperties();
+
+ // merge the store properties with the mapping provider properties
+ // the mapping provider props take precedence
+ final Properties properties = new Properties();
+
+ properties.putAll(storeProperties);
+ properties.putAll(mappingProviderProperties);
PackageRegistryProvider.getInstance().setThreadPackageRegistry(
getHibernateStore().getRepository().getPackageRegistry());
@@ -110,10 +112,13 @@ public class TeneoHibernateMappingProvider extends HibernateMappingProvider
properties.remove(PersistenceOptions.PERSISTENCE_XML);
}
- String hbm = CDOHelper.getInstance().generateMapping(ePackageArray, properties, extensionManager);
+ final CDOMappingGenerator mappingGenerator = new CDOMappingGenerator();
+ mappingGenerator.getExtensions().putAll(extensions);
+ String hbm = mappingGenerator.generateMapping(ePackageArray, properties);
// System.err.println(hbm);
// to solve an issue with older versions of teneo
- hbm = hbm.replaceAll("_cont", "cont");
+ hbm = hbm.replaceAll("_cont", "cont"); //$NON-NLS-1$ //$NON-NLS-2$
+
return hbm;
}
@@ -123,17 +128,27 @@ public class TeneoHibernateMappingProvider extends HibernateMappingProvider
{
final EClass eClass = EresourcePackage.eINSTANCE.getCDOResourceNode();
// already been here
- if (eClass.getEAnnotation("teneo.jpa") != null)
+ if (eClass.getEAnnotation("teneo.jpa") != null) //$NON-NLS-1$
{
return;
}
final EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- annotation.setSource("teneo.jpa");
- final String tableAnnotation = "@Table(uniqueConstraints={@UniqueConstraint(columnNames={\""
- + CDOHibernateConstants.CONTAINER_PROPERTY_COLUMN + "\", \""
- + EresourcePackage.eINSTANCE.getCDOResourceNode_Name().getName() + "\"})})";
- annotation.getDetails().put("value", tableAnnotation);
+ annotation.setSource("teneo.jpa"); //$NON-NLS-1$
+ final String tableAnnotation = "@Table(uniqueConstraints={@UniqueConstraint(columnNames={\"" //$NON-NLS-1$
+ + CDOHibernateConstants.CONTAINER_PROPERTY_COLUMN + "\", \"" //$NON-NLS-1$
+ + EresourcePackage.eINSTANCE.getCDOResourceNode_Name().getName() + "\"})})"; //$NON-NLS-1$
+ annotation.getDetails().put("value", tableAnnotation); //$NON-NLS-1$
eClass.getEAnnotations().add(annotation);
}
+
+ public Properties getMappingProviderProperties()
+ {
+ return mappingProviderProperties;
+ }
+
+ public void setMappingProviderProperties(Properties mappingProviderProperties)
+ {
+ this.mappingProviderProperties = mappingProviderProperties;
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProviderFactory.java b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProviderFactory.java
index c3364949c6..d81f9dd7bf 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProviderFactory.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProviderFactory.java
@@ -14,17 +14,28 @@ package org.eclipse.emf.cdo.server.hibernate.internal.teneo;
import org.eclipse.emf.cdo.server.hibernate.IHibernateMappingProvider;
import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.util.Properties;
/**
* Reads the hibernate mapping file from one or more resource locations and adds them to the configuration.
*
* @author Eike Stepper
- * @since 2.0
+ * @since 3.0
*/
public class TeneoHibernateMappingProviderFactory implements IHibernateMappingProvider.Factory
{
public static final String TYPE = "teneo"; //$NON-NLS-1$
+ private static final String PROPERTY_TAG = "property"; //$NON-NLS-1$
+
+ private static final String EXTENSION_TAG = "extension"; //$NON-NLS-1$
+
+ private static final String NAME_ATTR = "name"; //$NON-NLS-1$
+
+ private static final String VALUE_ATTR = "value"; //$NON-NLS-1$
+
public TeneoHibernateMappingProviderFactory()
{
}
@@ -36,6 +47,36 @@ public class TeneoHibernateMappingProviderFactory implements IHibernateMappingPr
public TeneoHibernateMappingProvider create(Element config)
{
- return new TeneoHibernateMappingProvider();
+
+ final Properties properties = new Properties();
+ final NodeList propertyNodes = config.getElementsByTagName(PROPERTY_TAG);
+ for (int i = 0; i < propertyNodes.getLength(); i++)
+ {
+ final Element propertyElement = (Element)propertyNodes.item(i);
+ properties.setProperty(propertyElement.getAttribute(NAME_ATTR), propertyElement.getAttribute(VALUE_ATTR));
+ }
+
+ final TeneoHibernateMappingProvider mappingProvider = new TeneoHibernateMappingProvider();
+ mappingProvider.setMappingProviderProperties(properties);
+ collectExtensions(config, mappingProvider);
+ return mappingProvider;
+ }
+
+ private void collectExtensions(Element config, TeneoHibernateMappingProvider mappingProvider)
+ {
+ final NodeList extensionNodes = config.getElementsByTagName(EXTENSION_TAG);
+ for (int i = 0; i < extensionNodes.getLength(); i++)
+ {
+ final Element extensionElement = (Element)extensionNodes.item(i);
+ final String nameAttrValue = extensionElement.getAttribute(NAME_ATTR);
+ final String valueAttrValue = extensionElement.getAttribute(VALUE_ATTR);
+ if (nameAttrValue == null || valueAttrValue == null)
+ {
+ throw new IllegalArgumentException(
+ "Extension element has incorrect format, both the name and value attribute should be present"); //$NON-NLS-1$
+ }
+
+ mappingProvider.putExtension(nameAttrValue, valueAttrValue);
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOBasicMapper.java b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOBasicMapper.java
index 975f2e43c8..619b54c03e 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOBasicMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOBasicMapper.java
@@ -1,55 +1,56 @@
-/**
- * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.hibernate.internal.teneo;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEAttribute;
-import org.eclipse.emf.teneo.hibernate.mapper.BasicMapper;
-import org.eclipse.emf.teneo.hibernate.mapper.HbMapperConstants;
-import org.eclipse.emf.teneo.simpledom.Element;
-
-/**
- * Extends enum mapping with parameters for epackage and eclass. This will be solved in the next build of Teneo.
- *
- * @author <a href="mtaal@elver.org">Martin Taal</a>
- */
-public class CDOBasicMapper extends BasicMapper
-{
- public CDOBasicMapper()
- {
- }
-
- @Override
- protected void setType(PAnnotatedEAttribute paAttribute, Element propElement)
- {
- super.setType(paAttribute, propElement);
- if (paAttribute.getEnumerated() != null)
- {
- final Element typeElement = propElement.element("type");
- for (Element element : typeElement.getChildren())
- {
- if (element.getName().equals(HbMapperConstants.ECLASSIFIER_PARAM))
- {
- // it has been done already
- return;
- }
- }
-
- // add the type elements
- final EAttribute eAttribute = paAttribute.getModelEAttribute();
- typeElement.addElement("param").addAttribute("name", HbMapperConstants.ECLASSIFIER_PARAM).addText(
- eAttribute.getEAttributeType().getName());
- typeElement.addElement("param").addAttribute("name", HbMapperConstants.EPACKAGE_PARAM).addText(
- eAttribute.getEAttributeType().getEPackage().getNsURI());
- }
- }
-}
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Taal - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.server.hibernate.teneo;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEAttribute;
+import org.eclipse.emf.teneo.hibernate.mapper.BasicMapper;
+import org.eclipse.emf.teneo.hibernate.mapper.HbMapperConstants;
+import org.eclipse.emf.teneo.simpledom.Element;
+
+/**
+ * Extends enum mapping with parameters for epackage and eclass. This will be solved in the next build of Teneo.
+ *
+ * @author <a href="mtaal@elver.org">Martin Taal</a>
+ * @since 3.0
+ */
+public class CDOBasicMapper extends BasicMapper
+{
+ public CDOBasicMapper()
+ {
+ }
+
+ @Override
+ protected void setType(PAnnotatedEAttribute paAttribute, Element propElement)
+ {
+ super.setType(paAttribute, propElement);
+ if (paAttribute.getEnumerated() != null)
+ {
+ final Element typeElement = propElement.element("type"); //$NON-NLS-1$
+ for (Element element : typeElement.getChildren())
+ {
+ if (element.getName().equals(HbMapperConstants.ECLASSIFIER_PARAM))
+ {
+ // it has been done already
+ return;
+ }
+ }
+
+ // add the type elements
+ final EAttribute eAttribute = paAttribute.getModelEAttribute();
+ typeElement.addElement("param").addAttribute("name", HbMapperConstants.ECLASSIFIER_PARAM).addText( //$NON-NLS-1$ //$NON-NLS-2$
+ eAttribute.getEAttributeType().getName());
+ typeElement.addElement("param").addAttribute("name", HbMapperConstants.EPACKAGE_PARAM).addText( //$NON-NLS-1$//$NON-NLS-2$
+ eAttribute.getEAttributeType().getEPackage().getNsURI());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOEDataTypeAnnotator.java b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOEDataTypeAnnotator.java
new file mode 100644
index 0000000000..f9b95397e3
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOEDataTypeAnnotator.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright (c) 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Taal - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.server.hibernate.teneo;
+
+import org.eclipse.emf.teneo.hibernate.annotations.HbEDataTypeAnnotator;
+
+/**
+ * Makes sure that the default type is a String.
+ *
+ * @author Martin Taal
+ * @since 3.0
+ */
+public class CDOEDataTypeAnnotator extends HbEDataTypeAnnotator
+{
+ public CDOEDataTypeAnnotator()
+ {
+ }
+
+ @Override
+ public String getDefaultUserType()
+ {
+ return "string"; //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOEFeatureAnnotator.java b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOEFeatureAnnotator.java
index e63fe1a294..f9c0c2db94 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOEFeatureAnnotator.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOEFeatureAnnotator.java
@@ -1,52 +1,53 @@
-/**
- * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.hibernate.internal.teneo;
-
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.teneo.annotations.mapper.EFeatureAnnotator;
-import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEReference;
-import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEStructuralFeature;
-import org.eclipse.emf.teneo.annotations.pannotation.PannotationFactory;
-
-/**
- * Extends the Teneo EFeatureAnnotator to add an external annotation to each EReference to an EModelElement.
- *
- * @author Martin Taal
- */
-public class CDOEFeatureAnnotator extends EFeatureAnnotator
-{
- public CDOEFeatureAnnotator()
- {
- }
-
- @Override
- public void annotate(PAnnotatedEStructuralFeature aStructuralFeature)
- {
- super.annotate(aStructuralFeature);
-
- // now determine if it needs to be annotated with External
- if (aStructuralFeature instanceof PAnnotatedEReference)
- {
- final PAnnotatedEReference paReference = (PAnnotatedEReference)aStructuralFeature;
- final boolean refersToEcoreModelElement = paReference.getModelEReference().getEReferenceType().getEPackage() == EcorePackage.eINSTANCE;
-
- // these are done with a <any ..> mapping
- final boolean refersToEObject = paReference.getModelEReference().getEReferenceType() == EcorePackage.eINSTANCE
- .getEObject();
- final boolean isPartOfEcoreModel = paReference.getModelEReference().getEContainingClass().getEPackage() == EcorePackage.eINSTANCE;
- if (refersToEcoreModelElement && !isPartOfEcoreModel && !refersToEObject)
- {
- paReference.setExternal(PannotationFactory.eINSTANCE.createExternal());
- }
- }
- }
-}
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Taal - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.server.hibernate.teneo;
+
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.teneo.annotations.mapper.EFeatureAnnotator;
+import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEReference;
+import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEStructuralFeature;
+import org.eclipse.emf.teneo.annotations.pannotation.PannotationFactory;
+
+/**
+ * Extends the Teneo EFeatureAnnotator to add an external annotation to each EReference to an EModelElement.
+ *
+ * @author Martin Taal
+ * @since 3.0
+ */
+public class CDOEFeatureAnnotator extends EFeatureAnnotator
+{
+ public CDOEFeatureAnnotator()
+ {
+ }
+
+ @Override
+ public void annotate(PAnnotatedEStructuralFeature aStructuralFeature)
+ {
+ super.annotate(aStructuralFeature);
+
+ // now determine if it needs to be annotated with External
+ if (aStructuralFeature instanceof PAnnotatedEReference)
+ {
+ final PAnnotatedEReference paReference = (PAnnotatedEReference)aStructuralFeature;
+ final boolean refersToEcoreModelElement = paReference.getModelEReference().getEReferenceType().getEPackage() == EcorePackage.eINSTANCE;
+
+ // these are done with a <any ..> mapping
+ final boolean refersToEObject = paReference.getModelEReference().getEReferenceType() == EcorePackage.eINSTANCE
+ .getEObject();
+ final boolean isPartOfEcoreModel = paReference.getModelEReference().getEContainingClass().getEPackage() == EcorePackage.eINSTANCE;
+ if (refersToEcoreModelElement && !isPartOfEcoreModel && !refersToEObject)
+ {
+ paReference.setExternal(PannotationFactory.eINSTANCE.createExternal());
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOEntityMapper.java b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOEntityMapper.java
index 1d6da81d82..ce04005663 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOEntityMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOEntityMapper.java
@@ -1,74 +1,75 @@
-package org.eclipse.emf.cdo.server.hibernate.internal.teneo;
-
-import org.eclipse.emf.cdo.eresource.EresourcePackage;
-import org.eclipse.emf.cdo.server.internal.hibernate.CDOHibernateConstants;
-import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDUserType;
-
-import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEClass;
-import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEStructuralFeature;
-import org.eclipse.emf.teneo.hibernate.mapper.EntityMapper;
-import org.eclipse.emf.teneo.simpledom.Element;
-
-import java.util.List;
-
-/**
- * Adds mapping for econtainer and eresource.
- *
- * @author <a href="mtaal@elver.org">Martin Taal</a>
- */
-public class CDOEntityMapper extends EntityMapper
-{
- private PAnnotatedEClass currentEntity;
-
- private boolean addedExtraMappings;
-
- public CDOEntityMapper()
- {
- }
-
- @Override
- public void processEntity(PAnnotatedEClass entity)
- {
- // not the nicest solution
- currentEntity = entity;
- try
- {
- addedExtraMappings = false;
- super.processEntity(entity);
- }
- finally
- {
- currentEntity = null;
- }
- }
-
- // add container and resource mappings
- @Override
- protected void processFeatures(List<PAnnotatedEStructuralFeature> features)
- {
- super.processFeatures(features);
-
- if (!addedExtraMappings && currentEntity.getPaSuperEntity() == null)
- {
- final Element entityElement = getHbmContext().getCurrent();
- final Element resourceElement = entityElement.addElement("property");
- resourceElement.addAttribute("name", CDOHibernateConstants.RESOURCE_PROPERTY);
- resourceElement.addElement("column").addAttribute("name", CDOHibernateConstants.RESOURCE_PROPERTY_COLUMN);
- resourceElement.addAttribute("type", CDOIDUserType.class.getName());
-
- final Element containerElement = entityElement.addElement("property");
- containerElement.addAttribute("name", CDOHibernateConstants.CONTAINER_PROPERTY).addAttribute("type", "string");
- final Element columnElement = containerElement.addElement("column").addAttribute("name",
- CDOHibernateConstants.CONTAINER_PROPERTY_COLUMN);
-
- if (getHbmContext().getCurrentEClass() == EresourcePackage.eINSTANCE.getCDOResourceNode())
- {
- // not nice but teneo will assign the first unique-key the number c0
- // and there is only one unique constraint
- columnElement.addAttribute("unique-key", "c0");
- }
-
- addedExtraMappings = true;
- }
- }
-}
+package org.eclipse.emf.cdo.server.hibernate.teneo;
+
+import org.eclipse.emf.cdo.eresource.EresourcePackage;
+import org.eclipse.emf.cdo.server.internal.hibernate.CDOHibernateConstants;
+import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDUserType;
+
+import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEClass;
+import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEStructuralFeature;
+import org.eclipse.emf.teneo.hibernate.mapper.EntityMapper;
+import org.eclipse.emf.teneo.simpledom.Element;
+
+import java.util.List;
+
+/**
+ * Adds mapping for econtainer and eresource.
+ *
+ * @author <a href="mtaal@elver.org">Martin Taal</a>
+ * @since 3.0
+ */
+public class CDOEntityMapper extends EntityMapper
+{
+ private PAnnotatedEClass currentEntity;
+
+ private boolean addedExtraMappings;
+
+ public CDOEntityMapper()
+ {
+ }
+
+ @Override
+ public void processEntity(PAnnotatedEClass entity)
+ {
+ // not the nicest solution
+ currentEntity = entity;
+ try
+ {
+ addedExtraMappings = false;
+ super.processEntity(entity);
+ }
+ finally
+ {
+ currentEntity = null;
+ }
+ }
+
+ // add container and resource mappings
+ @Override
+ protected void processFeatures(List<PAnnotatedEStructuralFeature> features)
+ {
+ super.processFeatures(features);
+
+ if (!addedExtraMappings && currentEntity.getPaSuperEntity() == null)
+ {
+ final Element entityElement = getHbmContext().getCurrent();
+ final Element resourceElement = entityElement.addElement("property"); //$NON-NLS-1$
+ resourceElement.addAttribute("name", CDOHibernateConstants.RESOURCE_PROPERTY); //$NON-NLS-1$
+ resourceElement.addElement("column").addAttribute("name", CDOHibernateConstants.RESOURCE_PROPERTY_COLUMN); //$NON-NLS-1$//$NON-NLS-2$
+ resourceElement.addAttribute("type", CDOIDUserType.class.getName()); //$NON-NLS-1$
+
+ final Element containerElement = entityElement.addElement("property"); //$NON-NLS-1$
+ containerElement.addAttribute("name", CDOHibernateConstants.CONTAINER_PROPERTY).addAttribute("type", "string"); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
+ final Element columnElement = containerElement.addElement("column").addAttribute("name", //$NON-NLS-1$ //$NON-NLS-2$
+ CDOHibernateConstants.CONTAINER_PROPERTY_COLUMN);
+
+ if (getHbmContext().getCurrentEClass() == EresourcePackage.eINSTANCE.getCDOResourceNode())
+ {
+ // not nice but teneo will assign the first unique-key the number c0
+ // and there is only one unique constraint
+ columnElement.addAttribute("unique-key", "c0"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ addedExtraMappings = true;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOHelper.java b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOHelper.java
deleted file mode 100644
index 02670e8b6a..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOHelper.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.hibernate.teneo;
-
-import org.eclipse.emf.cdo.server.hibernate.internal.teneo.CDOEFeatureAnnotator;
-import org.eclipse.emf.cdo.server.hibernate.internal.teneo.CDOManyAttributeMapper;
-import org.eclipse.emf.cdo.server.hibernate.internal.teneo.CDOMappingContext;
-import org.eclipse.emf.cdo.server.hibernate.internal.teneo.CDOXmlPersistenceContentHandler;
-
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.teneo.PersistenceOptions;
-import org.eclipse.emf.teneo.annotations.mapper.EFeatureAnnotator;
-import org.eclipse.emf.teneo.annotations.xml.XmlPersistenceContentHandler;
-import org.eclipse.emf.teneo.extension.ExtensionManager;
-import org.eclipse.emf.teneo.extension.ExtensionManagerFactory;
-import org.eclipse.emf.teneo.extension.ExtensionUtil;
-import org.eclipse.emf.teneo.hibernate.mapper.ManyAttributeMapper;
-import org.eclipse.emf.teneo.hibernate.mapper.MappingContext;
-import org.eclipse.emf.teneo.hibernate.mapper.MappingUtil;
-
-import java.util.Properties;
-
-/**
- * Offers convenience methods for generating a cdo enabled hibernate mapping.
- *
- * @author <a href="mtaal@elver.org">Martin Taal</a>
- * @since 3.0
- */
-public class CDOHelper
-{
- public static final String GENERATE_FOR_CDO = "generate_for_cdo";
-
- private static CDOHelper instance = new CDOHelper();
-
- /**
- * @return the instance
- */
- public static CDOHelper getInstance()
- {
- return instance;
- }
-
- /**
- * @param instance
- * the instance to set
- */
- public static void setInstance(CDOHelper instance)
- {
- CDOHelper.instance = instance;
- }
-
- public void registerCDOExtensions(ExtensionManager extensionManager)
- {
- MappingUtil.registerHbExtensions(extensionManager);
- extensionManager.registerExtension(ExtensionUtil.createExtension(MappingContext.class, CDOMappingContext.class,
- false));
- extensionManager.registerExtension(ExtensionUtil.createExtension(EFeatureAnnotator.class,
- CDOEFeatureAnnotator.class, false));
-
- extensionManager.registerExtension(ExtensionUtil.createExtension(ManyAttributeMapper.class,
- CDOManyAttributeMapper.class, false));
- extensionManager.registerExtension(ExtensionUtil.createExtension(XmlPersistenceContentHandler.class,
- CDOXmlPersistenceContentHandler.class, false));
- // extensionManager.registerExtension(ExtensionUtil.createExtension(BasicMapper.class, CDOBasicMapper.class,
- // false));
- }
-
- /**
- * Separate utility method, generates a hibernate mapping for a set of epackages and options. The hibernate.hbm.xml is
- * returned as a string. The mapping is not registered or used in any other way by Elver.
- */
- public String generateMapping(EPackage[] epackages, Properties props)
- {
- return generateMapping(epackages, props, ExtensionManagerFactory.getInstance().create());
- }
-
- /**
- * Separate utility method, generates a hibernate mapping for a set of epackages and options. The hibernate.hbm.xml is
- * returned as a string. The mapping is not registered or used in any other way by Elver.
- */
- public String generateMapping(EPackage[] epackages, Properties props, ExtensionManager extensionManager)
- {
- props.put(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
- props.put(PersistenceOptions.EMAP_AS_TRUE_MAP, "false");
- CDOHelper.getInstance().registerCDOExtensions(extensionManager);
- return MappingUtil.generateMapping(epackages, props, extensionManager);
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOManyAttributeMapper.java b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOManyAttributeMapper.java
index e45a59802a..ab25998f1d 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOManyAttributeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOManyAttributeMapper.java
@@ -1,31 +1,36 @@
-/**
- * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.hibernate.internal.teneo;
-
-import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEAttribute;
-import org.eclipse.emf.teneo.annotations.pannotation.FetchType;
-import org.eclipse.emf.teneo.hibernate.mapper.ManyAttributeMapper;
-
-/**
- * Extends the Teneo ManyAttributeMapper to force eager load of all primitive type lists.
- *
- * @author Martin Taal
- */
-public class CDOManyAttributeMapper extends ManyAttributeMapper
-{
- @Override
- public void processManyAttribute(PAnnotatedEAttribute paAttribute)
- {
- paAttribute.getOneToMany().setFetch(FetchType.EAGER);
- super.processManyAttribute(paAttribute);
- }
-}
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Taal - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.server.hibernate.teneo;
+
+import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEAttribute;
+import org.eclipse.emf.teneo.annotations.pannotation.FetchType;
+import org.eclipse.emf.teneo.hibernate.mapper.ManyAttributeMapper;
+
+/**
+ * Extends the Teneo ManyAttributeMapper to force eager load of all primitive type lists.
+ *
+ * @author Martin Taal
+ * @since 3.0
+ */
+public class CDOManyAttributeMapper extends ManyAttributeMapper
+{
+ public CDOManyAttributeMapper()
+ {
+ }
+
+ @Override
+ public void processManyAttribute(PAnnotatedEAttribute paAttribute)
+ {
+ paAttribute.getOneToMany().setFetch(FetchType.EAGER);
+ super.processManyAttribute(paAttribute);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOMappingContext.java b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOMappingContext.java
index 927b763be7..0f09c1ea04 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOMappingContext.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOMappingContext.java
@@ -1,154 +1,155 @@
-/**
- * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.hibernate.internal.teneo;
-
-import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOENumIntegerType;
-import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOENumStringType;
-import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDExternalUserType;
-import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer;
-import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOSyntheticIdPropertyHandler;
-import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOSyntheticVersionPropertyHandler;
-import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.FeatureMapEntryTuplizer;
-import org.eclipse.emf.cdo.spi.common.revision.CDOFeatureMapEntry;
-
-import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEClass;
-import org.eclipse.emf.teneo.extension.ExtensionManager;
-import org.eclipse.emf.teneo.hibernate.mapper.EntityMapper;
-import org.eclipse.emf.teneo.hibernate.mapper.MappingContext;
-import org.eclipse.emf.teneo.simpledom.Element;
-
-/**
- * Mapping context for CDO. It provides cdo classes as propertyhandler etc.
- *
- * @author <a href="mtaal@elver.org">Martin Taal</a>
- */
-public class CDOMappingContext extends MappingContext
-{
- public CDOMappingContext()
- {
- }
-
- /** Add a tuplizer element or not */
- @Override
- public void addTuplizerElement(Element entityElement, PAnnotatedEClass aclass)
- {
- Element tuplizerElement = new Element("tuplizer").addAttribute("entity-mode", "dynamic-map").addAttribute("class",
- CDORevisionTuplizer.class.getName());
- entityElement.add(0, tuplizerElement);
- tuplizerElement = new Element("tuplizer").addAttribute("entity-mode", "pojo").addAttribute("class",
- CDORevisionTuplizer.class.getName());
- entityElement.add(0, tuplizerElement);
- }
-
- @Override
- public void setExtensionManager(ExtensionManager extensionManager)
- {
- super.setExtensionManager(extensionManager);
- extensionManager.registerExtension(EntityMapper.class.getName(), CDOEntityMapper.class.getName());
- }
-
- @Override
- public String getComponentPropertyHandlerName()
- {
- return super.getComponentPropertyHandlerName();
- }
-
- @Override
- public String getIdPropertyHandlerName()
- {
- return null;
- }
-
- @Override
- public String getPropertyHandlerName()
- {
- return super.getPropertyHandlerName();
- }
-
- @Override
- public String getVersionPropertyHandlerName()
- {
- return null;
- }
-
- @Override
- public String getExternalUserType()
- {
- return CDOIDExternalUserType.class.getName();
- }
-
- @Override
- public String getComponentFeatureMapTuplizer()
- {
- return FeatureMapEntryTuplizer.class.getName();
- }
-
- @Override
- public String getFeatureMapEntryClassName()
- {
- return CDOFeatureMapEntry.class.getName();
- }
-
- @Override
- public String getEnumUserType()
- {
- return CDOENumStringType.class.getName();
- }
-
- @Override
- public String getEnumIntegerUserType()
- {
- return CDOENumIntegerType.class.getName();
- }
-
- @Override
- public String getSyntheticIdPropertyHandlerName()
- {
- return CDOSyntheticIdPropertyHandler.class.getName();
- }
-
- @Override
- public String getSyntheticVersionPropertyHandlerName()
- {
- return CDOSyntheticVersionPropertyHandler.class.getName();
- }
-
- @Override
- public String getDynamicEnumUserType()
- {
- return CDOENumStringType.class.getName();
- }
-
- @Override
- public String getDynamicEnumIntegerUserType()
- {
- return CDOENumIntegerType.class.getName();
- }
-
- @Override
- public String getDefaultUserType()
- {
- return super.getDefaultUserType();
- }
-
- @Override
- public String getXSDDateUserType()
- {
- return super.getXSDDateUserType();
- }
-
- @Override
- public String getXSDDateTimeUserType()
- {
- return super.getXSDDateTimeUserType();
- }
-}
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Taal - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.server.hibernate.teneo;
+
+import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOENumIntegerType;
+import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOENumStringType;
+import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDExternalUserType;
+import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer;
+import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOSyntheticIdPropertyHandler;
+import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOSyntheticVersionPropertyHandler;
+import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.FeatureMapEntryTuplizer;
+import org.eclipse.emf.cdo.spi.common.revision.CDOFeatureMapEntry;
+
+import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEClass;
+import org.eclipse.emf.teneo.extension.ExtensionManager;
+import org.eclipse.emf.teneo.hibernate.mapper.EntityMapper;
+import org.eclipse.emf.teneo.hibernate.mapper.MappingContext;
+import org.eclipse.emf.teneo.simpledom.Element;
+
+/**
+ * Mapping context for CDO. It provides cdo classes as propertyhandler etc.
+ *
+ * @author <a href="mtaal@elver.org">Martin Taal</a>
+ * @since 3.0
+ */
+public class CDOMappingContext extends MappingContext
+{
+ public CDOMappingContext()
+ {
+ }
+
+ /** Add a tuplizer element or not */
+ @Override
+ public void addTuplizerElement(Element entityElement, PAnnotatedEClass aclass)
+ {
+ Element tuplizerElement = new Element("tuplizer").addAttribute("entity-mode", "dynamic-map").addAttribute("class", //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ CDORevisionTuplizer.class.getName());
+ entityElement.add(0, tuplizerElement);
+ tuplizerElement = new Element("tuplizer").addAttribute("entity-mode", "pojo").addAttribute("class", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ CDORevisionTuplizer.class.getName());
+ entityElement.add(0, tuplizerElement);
+ }
+
+ @Override
+ public void setExtensionManager(ExtensionManager extensionManager)
+ {
+ super.setExtensionManager(extensionManager);
+ extensionManager.registerExtension(EntityMapper.class.getName(), CDOEntityMapper.class.getName());
+ }
+
+ @Override
+ public String getComponentPropertyHandlerName()
+ {
+ return super.getComponentPropertyHandlerName();
+ }
+
+ @Override
+ public String getIdPropertyHandlerName()
+ {
+ return null;
+ }
+
+ @Override
+ public String getPropertyHandlerName()
+ {
+ return super.getPropertyHandlerName();
+ }
+
+ @Override
+ public String getVersionPropertyHandlerName()
+ {
+ return null;
+ }
+
+ @Override
+ public String getExternalUserType()
+ {
+ return CDOIDExternalUserType.class.getName();
+ }
+
+ @Override
+ public String getComponentFeatureMapTuplizer()
+ {
+ return FeatureMapEntryTuplizer.class.getName();
+ }
+
+ @Override
+ public String getFeatureMapEntryClassName()
+ {
+ return CDOFeatureMapEntry.class.getName();
+ }
+
+ @Override
+ public String getEnumUserType()
+ {
+ return CDOENumStringType.class.getName();
+ }
+
+ @Override
+ public String getEnumIntegerUserType()
+ {
+ return CDOENumIntegerType.class.getName();
+ }
+
+ @Override
+ public String getSyntheticIdPropertyHandlerName()
+ {
+ return CDOSyntheticIdPropertyHandler.class.getName();
+ }
+
+ @Override
+ public String getSyntheticVersionPropertyHandlerName()
+ {
+ return CDOSyntheticVersionPropertyHandler.class.getName();
+ }
+
+ @Override
+ public String getDynamicEnumUserType()
+ {
+ return CDOENumStringType.class.getName();
+ }
+
+ @Override
+ public String getDynamicEnumIntegerUserType()
+ {
+ return CDOENumIntegerType.class.getName();
+ }
+
+ @Override
+ public String getDefaultUserType()
+ {
+ return "string"; //$NON-NLS-1$
+ }
+
+ @Override
+ public String getXSDDateUserType()
+ {
+ return super.getXSDDateUserType();
+ }
+
+ @Override
+ public String getXSDDateTimeUserType()
+ {
+ return super.getXSDDateTimeUserType();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOMappingGenerator.java b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOMappingGenerator.java
new file mode 100644
index 0000000000..0cf9ab60a4
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOMappingGenerator.java
@@ -0,0 +1,121 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Taal - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.server.hibernate.teneo;
+
+import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.teneo.PersistenceOptions;
+import org.eclipse.emf.teneo.annotations.mapper.EDataTypeAnnotator;
+import org.eclipse.emf.teneo.annotations.mapper.EFeatureAnnotator;
+import org.eclipse.emf.teneo.annotations.xml.XmlPersistenceContentHandler;
+import org.eclipse.emf.teneo.extension.ExtensionManager;
+import org.eclipse.emf.teneo.extension.ExtensionManagerFactory;
+import org.eclipse.emf.teneo.extension.ExtensionUtil;
+import org.eclipse.emf.teneo.hibernate.mapper.ManyAttributeMapper;
+import org.eclipse.emf.teneo.hibernate.mapper.MappingContext;
+import org.eclipse.emf.teneo.hibernate.mapper.MappingUtil;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Generates a CDO enabled mapping for Hibernate.
+ *
+ * @author <a href="mtaal@elver.org">Martin Taal</a>
+ * @since 3.0
+ */
+public class CDOMappingGenerator
+{
+ private static Map<String, String> extensions = new HashMap<String, String>();
+
+ private ExtensionManager extensionManager = ExtensionManagerFactory.getInstance().create();
+
+ public CDOMappingGenerator()
+ {
+ }
+
+ public void registerCDOExtensions(ExtensionManager extensionManager)
+ {
+ MappingUtil.registerHbExtensions(extensionManager);
+
+ // very strange but these can not go into the constructor...
+ // get a class not found exception then
+ addDefaultExtension(MappingContext.class, CDOMappingContext.class, extensionManager);
+ addDefaultExtension(EFeatureAnnotator.class, CDOEFeatureAnnotator.class, extensionManager);
+ addDefaultExtension(ManyAttributeMapper.class, CDOManyAttributeMapper.class, extensionManager);
+ addDefaultExtension(XmlPersistenceContentHandler.class, CDOXmlPersistenceContentHandler.class, extensionManager);
+ addDefaultExtension(EDataTypeAnnotator.class, CDOEDataTypeAnnotator.class, extensionManager);
+
+ for (String key : extensions.keySet())
+ {
+ try
+ {
+ final Class<?> keyClass = Thread.currentThread().getContextClassLoader().loadClass(key);
+ final Class<?> valueClass = Thread.currentThread().getContextClassLoader().loadClass(extensions.get(key));
+ extensionManager.registerExtension(ExtensionUtil.createExtension(keyClass, valueClass, false));
+ }
+ catch (Exception e)
+ {
+ throw new WrappedException(e);
+ }
+ }
+ }
+
+ protected void addDefaultExtension(Class<?> extensionClass, Class<?> extendingClass, ExtensionManager extensionManager)
+ {
+ if (extensions.containsKey(extensionClass.getName()))
+ {
+ return;
+ }
+
+ extensionManager.registerExtension(ExtensionUtil.createExtension(extensionClass, extendingClass, false));
+ }
+
+ public Map<String, String> getExtensions()
+ {
+ return extensions;
+ }
+
+ public void putExtension(String extensionClassName, String extendingClassName)
+ {
+ extensions.put(extensionClassName, extendingClassName);
+ }
+
+ /**
+ * Separate utility method, generates a hibernate mapping for a set of epackages and options. The hibernate.hbm.xml is
+ * returned as a string. The mapping is not registered or used in any other way by Elver.
+ */
+ public String generateMapping(EPackage[] epackages, Properties props)
+ {
+ // set some default properties
+ if (!props.containsKey(PersistenceOptions.ALWAYS_VERSION))
+ {
+ props.put(PersistenceOptions.ALWAYS_VERSION, "true"); //$NON-NLS-1$
+ }
+
+ if (!props.containsKey(PersistenceOptions.ID_COLUMN_NAME))
+ {
+ props.put(PersistenceOptions.ID_COLUMN_NAME, "idcol"); //$NON-NLS-1$
+ }
+
+ if (!props.containsKey(PersistenceOptions.VERSION_COLUMN_NAME))
+ {
+ props.put(PersistenceOptions.VERSION_COLUMN_NAME, "version"); //$NON-NLS-1$
+ }
+
+ props.put(PersistenceOptions.ALSO_MAP_AS_CLASS, "false"); //$NON-NLS-1$
+ props.put(PersistenceOptions.EMAP_AS_TRUE_MAP, "false"); //$NON-NLS-1$
+ registerCDOExtensions(extensionManager);
+ return MappingUtil.generateMapping(epackages, props, extensionManager);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOXmlPersistenceContentHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOXmlPersistenceContentHandler.java
index c03402d6d0..4d584ee67b 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/CDOXmlPersistenceContentHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOXmlPersistenceContentHandler.java
@@ -1,94 +1,99 @@
-/**
- * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.hibernate.internal.teneo;
-
-import org.eclipse.emf.cdo.server.hibernate.internal.teneo.bundle.OM;
-
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.teneo.PackageRegistryProvider;
-import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEPackage;
-import org.eclipse.emf.teneo.annotations.xml.XmlPersistenceContentHandler;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-/**
- * With cdo packages are registered at runtime so if the package in the xml is not yet present then be lenient about it.
- *
- * @author <a href="mtaal@elver.org">Martin Taal</a>
- */
-public class CDOXmlPersistenceContentHandler extends XmlPersistenceContentHandler
-{
- private PAnnotatedEPackage localPAPackage;
-
- // is also present in super class, should be made protected there
- private static final int ROOT = 0;
-
- @Override
- public void characters(char[] ch, int start, int length) throws SAXException
- {
- // unknown epackage, ignore for now
- if (localPAPackage == null)
- {
- return;
- }
-
- super.characters(ch, start, length);
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException
- {
- // unknown epackage, ignore for now
- if (localPAPackage == null)
- {
- return;
- }
-
- super.endElement(uri, localName, qName);
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
- {
- if (getParseState() != ROOT)
- {
- if (localName.equals("epackage"))
- {
- final String nameSpaceUri = attributes.getValue("namespace-uri");
- final EPackage ePackage = PackageRegistryProvider.getInstance().getPackageRegistry().getEPackage(nameSpaceUri);
- if (ePackage != null)
- {
- localPAPackage = getPAnnotatedModel().getPAnnotated(ePackage);
- }
- else
- {
- localPAPackage = null;
- }
-
- if (localPAPackage == null)
- {
- OM.LOG.warn("No EPackage found for namespace " + nameSpaceUri
- + ". This is not a problem if this EPackage is registered later.");
- }
- }
-
- // unknown epackage, ignore for now
- if (localPAPackage == null)
- {
- return;
- }
- }
-
- super.startElement(uri, localName, qName, attributes);
- }
-}
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Taal - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.server.hibernate.teneo;
+
+import org.eclipse.emf.cdo.server.hibernate.internal.teneo.bundle.OM;
+
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.teneo.PackageRegistryProvider;
+import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEPackage;
+import org.eclipse.emf.teneo.annotations.xml.XmlPersistenceContentHandler;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * With cdo packages are registered at runtime so if the package in the xml is not yet present then be lenient about it.
+ *
+ * @author <a href="mtaal@elver.org">Martin Taal</a>
+ * @since 3.0
+ */
+public class CDOXmlPersistenceContentHandler extends XmlPersistenceContentHandler
+{
+ private PAnnotatedEPackage localPAPackage;
+
+ // is also present in super class, should be made protected there
+ private static final int ROOT = 0;
+
+ public CDOXmlPersistenceContentHandler()
+ {
+ }
+
+ @Override
+ public void characters(char[] ch, int start, int length) throws SAXException
+ {
+ // unknown epackage, ignore for now
+ if (localPAPackage == null)
+ {
+ return;
+ }
+
+ super.characters(ch, start, length);
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) throws SAXException
+ {
+ // unknown epackage, ignore for now
+ if (localPAPackage == null)
+ {
+ return;
+ }
+
+ super.endElement(uri, localName, qName);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
+ {
+ if (getParseState() != ROOT)
+ {
+ if (localName.equals("epackage")) //$NON-NLS-1$
+ {
+ final String nameSpaceUri = attributes.getValue("namespace-uri"); //$NON-NLS-1$
+ final EPackage ePackage = PackageRegistryProvider.getInstance().getPackageRegistry().getEPackage(nameSpaceUri);
+ if (ePackage != null)
+ {
+ localPAPackage = getPAnnotatedModel().getPAnnotated(ePackage);
+ }
+ else
+ {
+ localPAPackage = null;
+ }
+
+ if (localPAPackage == null)
+ {
+ OM.LOG.warn("No EPackage found for namespace " + nameSpaceUri //$NON-NLS-1$
+ + ". This is not a problem if this EPackage is registered later."); //$NON-NLS-1$
+ }
+ }
+
+ // unknown epackage, ignore for now
+ if (localPAPackage == null)
+ {
+ return;
+ }
+ }
+
+ super.startElement(uri, localName, qName, attributes);
+ }
+}

Back to the top