Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormtaal2007-03-30 15:39:04 +0000
committermtaal2007-03-30 15:39:04 +0000
commit4bd9c9f2c94b3001927bb338be7453a9ca9c720e (patch)
tree794a7d1824cb0cc858b108512d1b132c09214c02
parent86bfb95f5acb9c02f83e2884779cfad44f9a9f0e (diff)
downloadorg.eclipse.emf.teneo-4bd9c9f2c94b3001927bb338be7453a9ca9c720e.tar.gz
org.eclipse.emf.teneo-4bd9c9f2c94b3001927bb338be7453a9ca9c720e.tar.xz
org.eclipse.emf.teneo-4bd9c9f2c94b3001927bb338be7453a9ca9c720e.zip
Solved multiple inheritance bug
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/JpoxDataStore.java12
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/MappingContext.java21
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/ManyToOneMapper.java6
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/OneToOneMapper.java6
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/property/BasicMapper.java6
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/property/InheritanceMapper.java13
6 files changed, 42 insertions, 22 deletions
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/JpoxDataStore.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/JpoxDataStore.java
index 3830d8bdc..16bbdf994 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/JpoxDataStore.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/JpoxDataStore.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: JpoxDataStore.java,v 1.9.2.2 2007/03/24 11:55:51 mtaal Exp $
+ * $Id: JpoxDataStore.java,v 1.9.2.3 2007/03/30 15:39:04 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox;
@@ -102,7 +102,7 @@ import org.w3c.dom.NodeList;
* contained in other classes.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.9.2.2 $ $Date: 2007/03/24 11:55:51 $
+ * @version $Revision: 1.9.2.3 $ $Date: 2007/03/30 15:39:04 $
*/
public class JpoxDataStore {
@@ -210,8 +210,8 @@ public class JpoxDataStore {
classNameList.append(",");
classNameList.append(AnyFeatureMapEntry.class.getName());
- properties.setProperty("org.jpox.autoStartMechanism", "Classes");
- properties.setProperty("org.jpox.autoStartClassNames", classNameList.toString());
+ properties.setProperty(PMFConfiguration.AUTO_START_MECHANISM_PROPERTY, "Classes");
+ properties.setProperty(PMFConfiguration.AUTO_START_CLASS_NAMES_PROPERTY, classNameList.toString());
// and then create a pmf which does all the work but does not check the schema all the time
pmf = JpoxHelper.INSTANCE.getPMFCreator().getPersistenceManagerFactory(properties);
@@ -550,7 +550,9 @@ public class JpoxDataStore {
// find the package name by going one level up.
String packageName = ((Element) classElement.getParentNode()).getAttribute("name");
className = ClassUtils.createFullClassName(packageName, className);
- result.add(className);
+ if (!result.contains(className)) {
+ result.add(className);
+ }
}
}
return result;
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/MappingContext.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/MappingContext.java
index c3b613311..b59cdf99e 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/MappingContext.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/MappingContext.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: MappingContext.java,v 1.5 2007/02/01 12:36:36 mtaal Exp $
+ * $Id: MappingContext.java,v 1.5.2.1 2007/03/30 15:39:04 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.mapper;
@@ -44,7 +44,7 @@ import org.eclipse.emf.teneo.jpox.mapper.property.TableMapper;
* Contains instances of the mappers used.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.5.2.1 $
*/
public class MappingContext extends AbstractProcessingContext {
@@ -117,6 +117,9 @@ public class MappingContext extends AbstractProcessingContext {
/** The epackages for which this is all done */
private EPackage[] epackages;
+ /** Force optional, in case of singletable */
+ private boolean forceOptional = false;
+
/** The constructor, creates all mappers etc. */
public MappingContext(EClassNameStrategy eclassNameStrategy) {
this.eclassNameStrategy = eclassNameStrategy;
@@ -288,4 +291,18 @@ public class MappingContext extends AbstractProcessingContext {
public void setEpackages(EPackage[] epackages) {
this.epackages = epackages;
}
+
+ /**
+ * @return the forceOptional
+ */
+ public boolean isForceOptional() {
+ return forceOptional;
+ }
+
+ /**
+ * @param forceOptional the forceOptional to set
+ */
+ public void setForceOptional(boolean forceOptional) {
+ this.forceOptional = forceOptional;
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/ManyToOneMapper.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/ManyToOneMapper.java
index f36b2519a..ae1cecb0a 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/ManyToOneMapper.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/ManyToOneMapper.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: ManyToOneMapper.java,v 1.8 2007/02/01 12:36:36 mtaal Exp $
+ * $Id: ManyToOneMapper.java,v 1.8.2.1 2007/03/30 15:39:04 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.mapper.association;
@@ -33,7 +33,7 @@ import org.eclipse.emf.teneo.simpledom.Element;
* Generates a jpox mapping for the one to one association.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.8.2.1 $
*/
public class ManyToOneMapper extends AssociationMapper {
@@ -68,7 +68,7 @@ public class ManyToOneMapper extends AssociationMapper {
// - its depedent child is deleted, the reference from o to the child is nullified
// - exception is thrown before o can be deleted that reference to child is null
// maybe required dependent is an uncommon model.
- boolean setNullable = aReference.getManyToOne().isOptional() || eReference.getEOpposite() != null
+ boolean setNullable = mappingContext.isForceOptional() || aReference.getManyToOne().isOptional() || eReference.getEOpposite() != null
|| cascadeRemove;
field.addAttribute("null-value", setNullable ? "none" : "exception");
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/OneToOneMapper.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/OneToOneMapper.java
index 67b6101d6..718ec8655 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/OneToOneMapper.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/OneToOneMapper.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: OneToOneMapper.java,v 1.7 2007/02/01 12:36:36 mtaal Exp $
+ * $Id: OneToOneMapper.java,v 1.7.2.1 2007/03/30 15:39:04 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.mapper.association;
@@ -31,7 +31,7 @@ import org.eclipse.emf.teneo.simpledom.Element;
* Generates a jpox mapping for the one to one association.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.7.2.1 $
*/
public class OneToOneMapper extends AssociationMapper {
@@ -66,7 +66,7 @@ public class OneToOneMapper extends AssociationMapper {
// - its depedent child is deleted, the reference from o to the child is nullified
// - exception is thrown before o can be deleted that reference to child is null
// maybe required dependent is an uncommon model.
- boolean setNullable = aReference.getOneToOne().isOptional() || eReference.getEOpposite() != null
+ boolean setNullable = mappingContext.isForceOptional() || aReference.getOneToOne().isOptional() || eReference.getEOpposite() != null
|| cascadeRemove;
field.addAttribute("null-value", setNullable ? "none" : "exception");
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/property/BasicMapper.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/property/BasicMapper.java
index f3436eab3..ccd0624eb 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/property/BasicMapper.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/property/BasicMapper.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: BasicMapper.java,v 1.5.2.1 2007/03/05 18:07:38 mtaal Exp $
+ * $Id: BasicMapper.java,v 1.5.2.2 2007/03/30 15:39:04 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.mapper.property;
@@ -34,7 +34,7 @@ import org.eclipse.emf.teneo.util.EcoreDataTypes;
* The abstract class for different mappers.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.5.2.1 $
+ * @version $Revision: 1.5.2.2 $
*/
public class BasicMapper extends AbstractMapper {
@@ -78,7 +78,7 @@ public class BasicMapper extends AbstractMapper {
}
// note defaults are handled by emf, so therefore no null-value=default
- field.addAttribute("null-value", (aAttribute.getBasic().isOptional() ? "none" : "exception"));
+ field.addAttribute("null-value", (mappingContext.isForceOptional() || aAttribute.getBasic().isOptional() ? "none" : "exception"));
final Class instanceClass = eAttribute.getEAttributeType().getInstanceClass();
final EDataType edatatype = eAttribute.getEAttributeType();
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/property/InheritanceMapper.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/property/InheritanceMapper.java
index 3c93799c6..8bbb7a999 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/property/InheritanceMapper.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/property/InheritanceMapper.java
@@ -11,18 +11,14 @@
* Martin Taal
* </copyright>
*
- * $Id: InheritanceMapper.java,v 1.5.2.1 2007/03/24 11:55:50 mtaal Exp $
+ * $Id: InheritanceMapper.java,v 1.5.2.2 2007/03/30 15:39:04 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.mapper.property;
-import java.util.Iterator;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.teneo.ERuntime;
import org.eclipse.emf.teneo.annotations.mapper.StoreMappingException;
import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEClass;
import org.eclipse.emf.teneo.annotations.pannotation.Inheritance;
@@ -35,7 +31,7 @@ import org.eclipse.emf.teneo.simpledom.Element;
* The abstract class for different mappers.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.5.2.1 $
+ * @version $Revision: 1.5.2.2 $
*/
public class InheritanceMapper extends AbstractMapper {
@@ -49,6 +45,9 @@ public class InheritanceMapper extends AbstractMapper {
/** Sets the inheritance strategy of the aclass and handles discriminator columns etc. */
public void map(PAnnotatedEClass aClass, Element classElement) {
+
+ mappingContext.setForceOptional(false); // the default
+
EClass eClass = aClass.getAnnotatedEClass();
Inheritance inheritance = getInheritance(aClass);
if (aClass.getMappedSuperclass() != null) {
@@ -66,6 +65,8 @@ public class InheritanceMapper extends AbstractMapper {
log.debug("Has superclasses therefore: superclass-table");
+ mappingContext.setForceOptional(true);
+
Element inheritanceElement = classElement.addElement("inheritance");
inheritanceElement.addAttribute("strategy", "superclass-table");

Back to the top