Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2012-08-23 05:16:19 -0400
committerMartin Taal2012-08-23 05:16:19 -0400
commit58e8a504aad68d6ff5b33b29bba2422d28ecdbaa (patch)
tree0ae8b994e4a7951dc6da61cc60a9ca832bf15d41 /generator/org.eclipse.emf.texo.orm
parentdfb7c88e1e8a7c72b7b7306b5d34328db4a71178 (diff)
downloadorg.eclipse.emf.texo-58e8a504aad68d6ff5b33b29bba2422d28ecdbaa.tar.gz
org.eclipse.emf.texo-58e8a504aad68d6ff5b33b29bba2422d28ecdbaa.tar.xz
org.eclipse.emf.texo-58e8a504aad68d6ff5b33b29bba2422d28ecdbaa.zip
Make Texo tests run with juno and latest hsqldb and eclipselink
Diffstat (limited to 'generator/org.eclipse.emf.texo.orm')
-rwxr-xr-xgenerator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EAttributeORMAnnotator.java36
-rwxr-xr-xgenerator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EClassORMAnnotator.java7
-rwxr-xr-xgenerator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EReferenceORMAnnotator.java2
-rw-r--r--generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EStructuralFeatureORMAnnotator.java6
-rwxr-xr-xgenerator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMNamingStrategy.java6
5 files changed, 46 insertions, 11 deletions
diff --git a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EAttributeORMAnnotator.java b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EAttributeORMAnnotator.java
index fb71c07b..d746f3d4 100755
--- a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EAttributeORMAnnotator.java
+++ b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EAttributeORMAnnotator.java
@@ -17,6 +17,7 @@
package org.eclipse.emf.texo.orm.annotator;
+import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Date;
@@ -157,7 +158,7 @@ public class EAttributeORMAnnotator extends EStructuralFeatureORMAnnotator imple
featureMapEntity.setName(namingStrategy.getFeatureMapEntityName(eAttribute));
}
- if (isPartOfFeatureMap && FeatureMapUtil.isFeatureMap(eAttribute)) {
+ if (isPartOfFeatureMap) {
if (annotation.getManyToOne() == null) {
annotation.setManyToOne(OrmFactory.eINSTANCE.createManyToOne());
}
@@ -170,13 +171,18 @@ public class EAttributeORMAnnotator extends EStructuralFeatureORMAnnotator imple
if (annotation.getOneToMany() == null) {
annotation.setOneToMany(OrmFactory.eINSTANCE.createOneToMany());
}
- final OneToMany OneToMany = annotation.getOneToMany();
- OneToMany.setTargetEntity(eAttributeModelGen.getFeatureMapQualifiedClassName());
- OneToMany.setCascade(OrmFactory.eINSTANCE.createCascadeType());
- OneToMany.setOrphanRemoval(true);
- OneToMany.getCascade().setCascadeAll(OrmFactory.eINSTANCE.createEmptyType());
- OneToMany.setJoinTable(OrmFactory.eINSTANCE.createJoinTable());
- OneToMany.setName(getName(eAttribute));
+ final OneToMany oneToMany = annotation.getOneToMany();
+ oneToMany.setTargetEntity(eAttributeModelGen.getFeatureMapQualifiedClassName());
+ oneToMany.setCascade(OrmFactory.eINSTANCE.createCascadeType());
+ oneToMany.setOrphanRemoval(true);
+ oneToMany.getCascade().setCascadeAll(OrmFactory.eINSTANCE.createEmptyType());
+ if (oneToMany.getJoinTable() == null) {
+ oneToMany.setJoinTable(OrmFactory.eINSTANCE.createJoinTable());
+ }
+ if (oneToMany.getJoinTable().getName() == null && namingStrategy.isGenerateAllDBSchemaNames()) {
+ oneToMany.getJoinTable().setName(namingStrategy.getJoinTableName(eAttribute));
+ }
+ oneToMany.setName(getName(eAttribute));
}
return;
@@ -186,11 +192,14 @@ public class EAttributeORMAnnotator extends EStructuralFeatureORMAnnotator imple
boolean isLob = false;
boolean isTime = false;
boolean isDate = false;
+ boolean isBigDecimal = false;
if (eDataType.getInstanceClass() != null) {
isLob = eDataType.getInstanceClass().isArray() && eDataType.getInstanceClass().getComponentType() == byte.class;
isTime = Timestamp.class == eDataType.getInstanceClass() || eDataType == XMLTypePackage.eINSTANCE.getDateTime();
isDate = eDataType == XMLTypePackage.eINSTANCE.getDate() || eDataType.getInstanceClass() != null
&& Date.class.isAssignableFrom(eDataType.getInstanceClass());
+ isBigDecimal = BigDecimal.class == eDataType.getInstanceClass()
+ || eDataType == XMLTypePackage.eINSTANCE.getDecimal();
}
final boolean isEnum = eDataType instanceof EEnum;
@@ -210,6 +219,12 @@ public class EAttributeORMAnnotator extends EStructuralFeatureORMAnnotator imple
elementCollection.setTemporal(TemporalType.TIMESTAMP);
} else if (isDate) {
elementCollection.setTemporal(TemporalType.DATE);
+ } else if (isBigDecimal && elementCollection.getColumn() == null
+ && ORMMappingOptions.getDefaultOptions().isTestRun()) {
+ final Column column = OrmFactory.eINSTANCE.createColumn();
+ column.setScale(7);
+ column.setPrecision(15);
+ elementCollection.setColumn(column);
} else if (doAddConverter(eAttributeModelGen)) {
elementCollection.setConvert(ORMUtils.OBJECT_CONVERTER_NAME);
}
@@ -297,6 +312,11 @@ public class EAttributeORMAnnotator extends EStructuralFeatureORMAnnotator imple
basic.setTemporal(TemporalType.TIMESTAMP);
} else if (!basicSet && isDate) {
basic.setTemporal(TemporalType.DATE);
+ } else if (isBigDecimal && basic.getColumn() == null && ORMMappingOptions.getDefaultOptions().isTestRun()) {
+ final Column column = OrmFactory.eINSTANCE.createColumn();
+ column.setScale(7);
+ column.setPrecision(15);
+ basic.setColumn(column);
} else if (doAddConverter(eAttributeModelGen)) {
basic.setConvert(ORMUtils.OBJECT_CONVERTER_NAME);
}
diff --git a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EClassORMAnnotator.java b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EClassORMAnnotator.java
index 5179854b..410b93a2 100755
--- a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EClassORMAnnotator.java
+++ b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EClassORMAnnotator.java
@@ -25,6 +25,7 @@ import org.eclipse.emf.texo.modelgenerator.annotator.GenUtils;
import org.eclipse.emf.texo.modelgenerator.modelannotations.EClassModelGenAnnotation;
import org.eclipse.emf.texo.modelgenerator.modelannotations.ModelcodegeneratorPackage;
import org.eclipse.emf.texo.orm.annotations.model.orm.AccessType;
+import org.eclipse.emf.texo.orm.annotations.model.orm.DiscriminatorColumn;
import org.eclipse.emf.texo.orm.annotations.model.orm.Entity;
import org.eclipse.emf.texo.orm.annotations.model.orm.MappedSuperclass;
import org.eclipse.emf.texo.orm.annotations.model.orm.OrmFactory;
@@ -118,6 +119,12 @@ public class EClassORMAnnotator extends ETypeElementORMAnnotator implements Anno
}
}
+ if (isRoot(annotation) && ORMMappingOptions.getDefaultOptions().isTestRun()) {
+ final DiscriminatorColumn dc = OrmFactory.eINSTANCE.createDiscriminatorColumn();
+ dc.setLength(255);
+ entity.setDiscriminatorColumn(dc);
+ }
+
// with interfaces always access through the property
if (eClass.isInterface()) {
entity.setAccess(AccessType.PROPERTY);
diff --git a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EReferenceORMAnnotator.java b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EReferenceORMAnnotator.java
index a3ca563e..5f30bc41 100755
--- a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EReferenceORMAnnotator.java
+++ b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EReferenceORMAnnotator.java
@@ -284,7 +284,7 @@ public class EReferenceORMAnnotator extends EStructuralFeatureORMAnnotator imple
if (namingStrategy.isGenerateAllDBSchemaNames()) {
if (oneToMany.getJoinTable() != null) {
// set a unique name
- if (oneToMany.getJoinTable() != null && GeneratorUtils.isEmptyOrNull(oneToMany.getJoinTable().getName())) {
+ if (GeneratorUtils.isEmptyOrNull(oneToMany.getJoinTable().getName())) {
oneToMany.getJoinTable().setName(namingStrategy.getJoinTableName(eReference));
}
addColumnsToJoinTable(namingStrategy, oneToMany.getJoinTable(), annotation);
diff --git a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EStructuralFeatureORMAnnotator.java b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EStructuralFeatureORMAnnotator.java
index 7f6f19ea..f9d78288 100644
--- a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EStructuralFeatureORMAnnotator.java
+++ b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EStructuralFeatureORMAnnotator.java
@@ -19,6 +19,7 @@ package org.eclipse.emf.texo.orm.annotator;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.FeatureMapUtil;
import org.eclipse.emf.texo.modelgenerator.modelannotations.EStructuralFeatureModelGenAnnotation;
import org.eclipse.emf.texo.utils.ModelUtils;
@@ -32,7 +33,8 @@ import org.eclipse.emf.texo.utils.ModelUtils;
public class EStructuralFeatureORMAnnotator extends ETypeElementORMAnnotator {
protected boolean doAddConverter(EStructuralFeatureModelGenAnnotation annotation) {
- if (FeatureMapUtil.isFeatureMap(annotation.getEStructuralFeature())) {
+ final EStructuralFeature eFeature = annotation.getEStructuralFeature();
+ if (FeatureMapUtil.isFeatureMap(eFeature)) {
return false;
}
if (!ORMMappingOptions.getDefaultOptions().isTestRun()) {
@@ -41,7 +43,7 @@ public class EStructuralFeatureORMAnnotator extends ETypeElementORMAnnotator {
if (annotation.getEStructuralFeature().getEType() instanceof EEnum) {
return false;
}
- if (ModelUtils.isAnyType(annotation.getEStructuralFeature())) {
+ if (ModelUtils.isAnyType(eFeature)) {
return true;
}
if (annotation.getObjectType() != null
diff --git a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMNamingStrategy.java b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMNamingStrategy.java
index 65bfb220..b54168f6 100755
--- a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMNamingStrategy.java
+++ b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMNamingStrategy.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
import org.eclipse.emf.texo.generator.GeneratorUtils;
import org.eclipse.emf.texo.orm.ormannotations.EPackageORMAnnotation;
@@ -171,6 +172,11 @@ public class ORMNamingStrategy {
if (localName == null) {
localName = getEntityName(eFeature.getEContainingClass()) + "_" + eFeature.getName(); //$NON-NLS-1$
}
+ // add a postfix to make it unique, as often a nameclash occurs with the
+ // featuremap entry table
+ if (FeatureMapUtil.isFeatureMap(eFeature)) {
+ localName += "_FM";
+ }
return processName(localName, ePackageORMAnnotation.getTableNamePrefix());
}

Back to the top