Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormtaal2007-03-30 15:38:47 +0000
committermtaal2007-03-30 15:38:47 +0000
commit8837da8d03a0af2ada74d68b420e632cbcc65bcc (patch)
tree39d1c9d6f733e8de1804c93ed018707d62856870
parent83c2239d22a088d94a076934e8b85b285457ab5a (diff)
downloadorg.eclipse.emf.teneo-8837da8d03a0af2ada74d68b420e632cbcc65bcc.tar.gz
org.eclipse.emf.teneo-8837da8d03a0af2ada74d68b420e632cbcc65bcc.tar.xz
org.eclipse.emf.teneo-8837da8d03a0af2ada74d68b420e632cbcc65bcc.zip
Solved multiple inheritance bug
-rw-r--r--plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/hbannotation/util/HibernateDefaultAnnotator.java14
-rw-r--r--plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/BasicMapper.java11
-rw-r--r--plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/EntityMapper.java11
-rw-r--r--plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/ManyToOneMapper.java10
-rw-r--r--plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/MappingContext.java21
-rw-r--r--plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/OneToOneMapper.java7
6 files changed, 49 insertions, 25 deletions
diff --git a/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/hbannotation/util/HibernateDefaultAnnotator.java b/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/hbannotation/util/HibernateDefaultAnnotator.java
index d4286b50f..58d96a54a 100644
--- a/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/hbannotation/util/HibernateDefaultAnnotator.java
+++ b/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/hbannotation/util/HibernateDefaultAnnotator.java
@@ -12,7 +12,7 @@
* Michael Kanaley, TIBCO Software Inc., custom type handling
* </copyright>
*
- * $Id: HibernateDefaultAnnotator.java,v 1.4.2.2 2007/03/24 11:55:52 mtaal Exp $
+ * $Id: HibernateDefaultAnnotator.java,v 1.4.2.3 2007/03/30 15:38:48 mtaal Exp $
*/
package org.eclipse.emf.teneo.hibernate.hbannotation.util;
@@ -96,7 +96,7 @@ public class HibernateDefaultAnnotator extends DefaultAnnotator {
/**
* Process one to many attribute. In case collection of elements was present use it to set target entity
*/
- protected void processOneToManyAttribute(PAnnotatedEAttribute aAttribute, boolean forceNullable) {
+ protected void processOneToManyAttribute(PAnnotatedEAttribute aAttribute) {
boolean isCollectionOfElements = (aAttribute instanceof HbAnnotatedEAttribute && null != ((HbAnnotatedEAttribute) aAttribute)
.getHbCollectionOfElements());
@@ -113,15 +113,15 @@ public class HibernateDefaultAnnotator extends DefaultAnnotator {
// assume this to be a single attribute, we can get here when
// the instance is an array or list in that case the user type is assumed
// to be able to handle the complete list/collection
- super.processSingleAttribute(aAttribute, forceNullable);
+ super.processSingleAttribute(aAttribute);
} else if (hed != null && hed.getHbTypeDef() != null && hea.getOneToMany() == null
&& !aAttribute.getAnnotatedEAttribute().isMany()) {
// assume this to be a single attribute, we can get here when
// the instance is an array or list in that case the user type is assumed
// to be able to handle the complete list/collection
- super.processSingleAttribute(aAttribute, forceNullable);
+ super.processSingleAttribute(aAttribute);
} else {
- super.processOneToManyAttribute(aAttribute, forceNullable);
+ super.processOneToManyAttribute(aAttribute);
}
}
@@ -173,11 +173,11 @@ public class HibernateDefaultAnnotator extends DefaultAnnotator {
* Ignored collection of elements on many reference, collection of elements should be handled by method above. Adds
* default caching if set.
*/
- protected void processOneToManyReference(PAnnotatedEReference aReference, boolean forceOptional) {
+ protected void processOneToManyReference(PAnnotatedEReference aReference) {
boolean isCollectionOfElements = (aReference instanceof HbAnnotatedEReference && null != ((HbAnnotatedEReference) aReference)
.getHbCollectionOfElements());
if (!isCollectionOfElements) {
- super.processOneToManyReference(aReference, forceOptional);
+ super.processOneToManyReference(aReference);
}
// now handle the case of defaultCacheStrategy which is different than none
diff --git a/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/BasicMapper.java b/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/BasicMapper.java
index 49b1ddf48..bf2a836e2 100644
--- a/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/BasicMapper.java
+++ b/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/BasicMapper.java
@@ -12,7 +12,7 @@
* Davide Marchignoli
* </copyright>
*
- * $Id: BasicMapper.java,v 1.9 2007/02/08 23:13:12 mtaal Exp $
+ * $Id: BasicMapper.java,v 1.8.2.1 2007/03/30 15:38:48 mtaal Exp $
*/
package org.eclipse.emf.teneo.hibernate.mapper;
@@ -27,7 +27,6 @@ import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEAttribute;
import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEStructuralFeature;
import org.eclipse.emf.teneo.annotations.pannotation.Basic;
-import org.eclipse.emf.teneo.annotations.pannotation.Column;
import org.eclipse.emf.teneo.annotations.pannotation.Enumerated;
import org.eclipse.emf.teneo.annotations.pannotation.FetchType;
import org.eclipse.emf.teneo.annotations.pannotation.PannotationFactory;
@@ -156,7 +155,7 @@ class BasicMapper extends AbstractPropertyMapper {
basic = PannotationFactory.eINSTANCE.createBasic();
}
- final List<Column> columns = getColumns(paAttribute);
+ final List columns = getColumns(paAttribute);
final Element propElement = getHbmContext().getCurrent().addElement("property").addAttribute("name",
getHbmContext().getPropertyName(paAttribute.getAnnotatedEAttribute()));
@@ -175,7 +174,7 @@ class BasicMapper extends AbstractPropertyMapper {
if (hed.getHbTypeDef() != null || hea.getHbType() != null) {
setType(paAttribute, propElement);
} else if (getHbmContext().isEasyEMFGenerated(eclassifier)) {
- final Class<?> instanceClass = getHbmContext().getImpl(eclassifier);
+ final Class instanceClass = getHbmContext().getImpl(eclassifier);
propElement.addElement("type").addAttribute("name", getEnumUserType(enumerated)).addElement("param")
.addAttribute("name", "enumClassName").addText(instanceClass.getName());
} else if (getHbmContext().isEasyEMFDynamic(eclassifier)) {
@@ -209,7 +208,7 @@ class BasicMapper extends AbstractPropertyMapper {
final EAttribute eAttribute = paAttribute.getAnnotatedEAttribute();
final Element propElement = getHbmContext().getCurrent().addElement("version").addAttribute("name",
eAttribute.getName());
- List<Column> columns = getColumns(paAttribute);
+ List columns = getColumns(paAttribute);
if (columns.size() > 1) {
log.warn("Version has more than one attribute, only using the first one, eclass: "
+ paAttribute.getAnnotatedEAttribute().getEContainingClass().getName());
@@ -236,6 +235,6 @@ class BasicMapper extends AbstractPropertyMapper {
* featuremapentries will have all the features of the featuremap with only one of them filled.
*/
private boolean isNullable(Basic basic, EAttribute eattr) {
- return basic.isOptional() || getHbmContext().isCurrentElementFeatureMap();
+ return getHbmContext().isForceNullable() || basic.isOptional() || getHbmContext().isCurrentElementFeatureMap();
}
}
diff --git a/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/EntityMapper.java b/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/EntityMapper.java
index 5c3e1af6f..61c778e5a 100644
--- a/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/EntityMapper.java
+++ b/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/EntityMapper.java
@@ -12,7 +12,7 @@
* Davide Marchignoli
* </copyright>
*
- * $Id: EntityMapper.java,v 1.8.2.1 2007/03/21 16:09:30 mtaal Exp $
+ * $Id: EntityMapper.java,v 1.8.2.2 2007/03/30 15:38:48 mtaal Exp $
*/
package org.eclipse.emf.teneo.hibernate.mapper;
@@ -238,6 +238,14 @@ class EntityMapper extends AbstractMapper {
}
try {
+
+ getHbmContext()
+ .setForceNullable(
+ entity.getPaSuperEntity() != null
+ && (entity.getInheritanceStrategy() == null || InheritanceType.SINGLE_TABLE_LITERAL
+ .equals(entity
+ .getInheritanceStrategy())));
+
final List multipleInheritanceFeatures = getHbmContext().getInheritedFeatures(entity);
getHbmContext().pushOverrideOnStack();
if (entity.getAttributeOverrides() != null) {
@@ -262,6 +270,7 @@ class EntityMapper extends AbstractMapper {
processSecondaryTables(secondaryTables, entity);
}
} finally {
+ getHbmContext().setForceNullable(false);
getHbmContext().setCurrentTable(null);
Element idElement = entityElement.element("id");
if (idElement == null) {
diff --git a/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/ManyToOneMapper.java b/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/ManyToOneMapper.java
index 3bf0ccb9d..83bfc0b9e 100644
--- a/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/ManyToOneMapper.java
+++ b/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/ManyToOneMapper.java
@@ -12,7 +12,7 @@
* Davide Marchignoli
* </copyright>
*
- * $Id: ManyToOneMapper.java,v 1.7 2007/02/08 23:13:12 mtaal Exp $
+ * $Id: ManyToOneMapper.java,v 1.6.2.1 2007/03/30 15:38:47 mtaal Exp $
*/
package org.eclipse.emf.teneo.hibernate.mapper;
@@ -24,7 +24,6 @@ import org.apache.commons.logging.LogFactory;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEReference;
import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEStructuralFeature;
-import org.eclipse.emf.teneo.annotations.pannotation.JoinColumn;
import org.eclipse.emf.teneo.annotations.pannotation.ManyToOne;
import org.eclipse.emf.teneo.simpledom.Element;
@@ -56,7 +55,7 @@ class ManyToOneMapper extends AbstractAssociationMapper {
public void process(PAnnotatedEReference paReference) {
log.debug("Process many-to-one " + paReference);
- final List<JoinColumn> jcs = getJoinColumns(paReference);
+ final List jcs = getJoinColumns(paReference);
if (jcs.size() > 1) { // TODO support multiple join columns
log.error("Unsupported multiple join columns in " + paReference);
throw new MappingException("Unsupported multiple join columns", paReference);
@@ -87,9 +86,10 @@ class ManyToOneMapper extends AbstractAssociationMapper {
associationElement.addAttribute("lazy", "false");
}
- addJoinColumns(associationElement, jcs, mto.isOptional() || getHbmContext().isCurrentElementFeatureMap());
+ addJoinColumns(associationElement, jcs, getHbmContext().isForceNullable() || mto.isOptional()
+ || getHbmContext().isCurrentElementFeatureMap());
- associationElement.addAttribute("not-null", mto.isOptional()
+ associationElement.addAttribute("not-null", getHbmContext().isForceNullable() || mto.isOptional()
|| getHbmContext().isCurrentElementFeatureMap() ? "false" : "true");
}
diff --git a/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/MappingContext.java b/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/MappingContext.java
index a10ad3993..aa4601618 100644
--- a/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/MappingContext.java
+++ b/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/MappingContext.java
@@ -12,7 +12,7 @@
* Davide Marchignoli
* </copyright>
*
- * $Id: MappingContext.java,v 1.8.2.1 2007/03/18 22:34:33 mtaal Exp $
+ * $Id: MappingContext.java,v 1.8.2.2 2007/03/30 15:38:48 mtaal Exp $
*/
package org.eclipse.emf.teneo.hibernate.mapper;
@@ -47,7 +47,7 @@ import org.eclipse.emf.teneo.util.SQLCaseStrategy;
* Maps a basic attribute with many=true, e.g. list of simpletypes.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.8.2.1 $
+ * @version $Revision: 1.8.2.2 $
*/
public class MappingContext extends AbstractProcessingContext {
@@ -109,6 +109,9 @@ public class MappingContext extends AbstractProcessingContext {
private SQLCaseStrategy sqlCaseStrategy;
private boolean alwaysVersion;
+
+ /** Force to null, is used in case of single-table to nullable subclass fields */
+ private boolean forceNullable = false;
/** The constructor */
public MappingContext() {
@@ -529,4 +532,18 @@ public class MappingContext extends AbstractProcessingContext {
public void setCurrentEFeature(EStructuralFeature currentEFeature) {
this.currentEFeature = currentEFeature;
}
+
+ /**
+ * @return the forceNullable
+ */
+ public boolean isForceNullable() {
+ return forceNullable;
+ }
+
+ /**
+ * @param forceNullable the forceNullable to set
+ */
+ public void setForceNullable(boolean forceNullable) {
+ this.forceNullable = forceNullable;
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/OneToOneMapper.java b/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/OneToOneMapper.java
index 5915b326d..be6c871cc 100644
--- a/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/OneToOneMapper.java
+++ b/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/OneToOneMapper.java
@@ -12,7 +12,7 @@
* Davide Marchignoli
* </copyright>
*
- * $Id: OneToOneMapper.java,v 1.8 2007/02/08 23:13:12 mtaal Exp $
+ * $Id: OneToOneMapper.java,v 1.7.2.1 2007/03/30 15:38:48 mtaal Exp $
*/
package org.eclipse.emf.teneo.hibernate.mapper;
@@ -25,7 +25,6 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEReference;
import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEStructuralFeature;
-import org.eclipse.emf.teneo.annotations.pannotation.JoinColumn;
import org.eclipse.emf.teneo.annotations.pannotation.OneToOne;
import org.eclipse.emf.teneo.annotations.pannotation.PannotationPackage;
import org.eclipse.emf.teneo.simpledom.Element;
@@ -93,8 +92,8 @@ class OneToOneMapper extends AbstractAssociationMapper {
} else {
associationElement.addAttribute("lazy", "false");
}
- final List<JoinColumn> joinColumns = getJoinColumns(paReference);
- final boolean forceNullable = (oto.isOptional() || getHbmContext().isCurrentElementFeatureMap());
+ final List joinColumns = getJoinColumns(paReference);
+ final boolean forceNullable = getHbmContext().isForceNullable() || oto.isOptional() || getHbmContext().isCurrentElementFeatureMap();
addJoinColumns(associationElement, joinColumns, forceNullable);
associationElement.addAttribute("unique", "true");

Back to the top