diff options
author | Martin Taal | 2013-11-17 22:21:16 +0000 |
---|---|---|
committer | Martin Taal | 2013-11-17 22:21:16 +0000 |
commit | 8ed2c2ccc76793e02a1cc9eea80b23eea6282eab (patch) | |
tree | e2f83b8a628e43d8a0a3f5e718f93b6ba0f865aa | |
parent | 6670b44e161638fe7ad59ddd3b2b7889494048d3 (diff) | |
download | org.eclipse.emf.teneo-8ed2c2ccc76793e02a1cc9eea80b23eea6282eab.tar.gz org.eclipse.emf.teneo-8ed2c2ccc76793e02a1cc9eea80b23eea6282eab.tar.xz org.eclipse.emf.teneo-8ed2c2ccc76793e02a1cc9eea80b23eea6282eab.zip |
[420463] - implement columnDefinition handling for DiscriminatorColumn annotation
12 files changed, 51 insertions, 44 deletions
diff --git a/hibernate/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/EntityMapper.java b/hibernate/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/EntityMapper.java index 8c81e03e9..1d7eef7dd 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/EntityMapper.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/EntityMapper.java @@ -697,6 +697,9 @@ public class EntityMapper extends AbstractMapper implements ExtensionPoint { if (!col.isNullable()) { colElement.addAttribute("not-null", "true"); } + if (col.getColumnDefinition() != null) { + colElement.addAttribute("sql-type", col.getColumnDefinition()); + } } else if (dColumn.getName() != null) { dcElement.addAttribute("column", getHbmContext().trunc(dColumn, dColumn.getName())); } @@ -711,9 +714,17 @@ public class EntityMapper extends AbstractMapper implements ExtensionPoint { } if (dColumn.getColumnDefinition() != null) { - log.error("Unsupported column definition in discriminator column " + dColumn); - throw new MappingException("Unsupported column definition in discriminator column", dColumn); + String colName = dcElement.getAttributeValue("column"); + Element colElement = dcElement.element("column"); + if (colElement == null) { + colElement = dcElement.addElement("column"); + if (colName != null && colElement.getAttributeValue("name") == null) { + colElement.addAttribute("name", colName); + } + } + colElement.addAttribute("sql-type", dColumn.getColumnDefinition()); } + return dcElement; } diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.emf.annotations/InheritanceAnnotationAction_hsqldb_e_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.emf.annotations/InheritanceAnnotationAction_hsqldb_e_o_hibernate.hbm.xml index 1ab993afe..d8a5952ec 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.emf.annotations/InheritanceAnnotationAction_hsqldb_e_o_hibernate.hbm.xml +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.emf.annotations/InheritanceAnnotationAction_hsqldb_e_o_hibernate.hbm.xml @@ -74,7 +74,7 @@ <generator class="native"/> </id> <discriminator type="string"> - <column name="`DISCRIMINATOR`" index="discrIndex,ohterindex" length="120"/> + <column name="`DISCRIMINATOR`" index="discrIndex,ohterindex" length="120" sql-type="character varying (100) "/> </discriminator> <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> <meta attribute="syntheticVersion" inherit="false">true</meta> diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.emf.annotations/InheritanceAnnotationAction_hsqldb_h_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.emf.annotations/InheritanceAnnotationAction_hsqldb_h_o_hibernate.hbm.xml index 6a914e5bc..d9da6206f 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.emf.annotations/InheritanceAnnotationAction_hsqldb_h_o_hibernate.hbm.xml +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.emf.annotations/InheritanceAnnotationAction_hsqldb_h_o_hibernate.hbm.xml @@ -77,7 +77,7 @@ <generator class="native"/> </id> <discriminator type="string"> - <column name="`DISCRIMINATOR`" index="discrIndex,ohterindex" length="120"/> + <column name="`DISCRIMINATOR`" index="discrIndex,ohterindex" length="120" sql-type="character varying (100) "/> </discriminator> <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> <meta attribute="syntheticVersion" inherit="false">true</meta> diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.emf.annotations/InheritanceAnnotationTablePerClassAction_hsqldb_e_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.emf.annotations/InheritanceAnnotationTablePerClassAction_hsqldb_e_o_hibernate.hbm.xml index 1ab993afe..d8a5952ec 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.emf.annotations/InheritanceAnnotationTablePerClassAction_hsqldb_e_o_hibernate.hbm.xml +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.emf.annotations/InheritanceAnnotationTablePerClassAction_hsqldb_e_o_hibernate.hbm.xml @@ -74,7 +74,7 @@ <generator class="native"/> </id> <discriminator type="string"> - <column name="`DISCRIMINATOR`" index="discrIndex,ohterindex" length="120"/> + <column name="`DISCRIMINATOR`" index="discrIndex,ohterindex" length="120" sql-type="character varying (100) "/> </discriminator> <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> <meta attribute="syntheticVersion" inherit="false">true</meta> diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.emf.annotations/InheritanceAnnotationTablePerClassAction_hsqldb_h_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.emf.annotations/InheritanceAnnotationTablePerClassAction_hsqldb_h_o_hibernate.hbm.xml index 6a914e5bc..d9da6206f 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.emf.annotations/InheritanceAnnotationTablePerClassAction_hsqldb_h_o_hibernate.hbm.xml +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.emf.annotations/InheritanceAnnotationTablePerClassAction_hsqldb_h_o_hibernate.hbm.xml @@ -77,7 +77,7 @@ <generator class="native"/> </id> <discriminator type="string"> - <column name="`DISCRIMINATOR`" index="discrIndex,ohterindex" length="120"/> + <column name="`DISCRIMINATOR`" index="discrIndex,ohterindex" length="120" sql-type="character varying (100) "/> </discriminator> <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> <meta attribute="syntheticVersion" inherit="false">true</meta> diff --git a/tests/org.eclipse.emf.teneo.samples/plugin.xml b/tests/org.eclipse.emf.teneo.samples/plugin.xml index 3cb83a360..23ed23cad 100755 --- a/tests/org.eclipse.emf.teneo.samples/plugin.xml +++ b/tests/org.eclipse.emf.teneo.samples/plugin.xml @@ -37,4 +37,18 @@ type="bz398161" class="org.eclipse.emf.teneo.samples.issues.bz398161.util.Bz398161ResourceFactoryImpl"/> </extension> + <extension point="org.eclipse.emf.ecore.generated_package"> + <!-- @generated inheritancemapping --> + <package + uri="http://www.eclipse.org/emf/teneo/samples/emf/annotations/inheritancemapping" + class="org.eclipse.emf.teneo.samples.emf.annotations.inheritancemapping.InheritancemappingPackage" + genModel="src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/model/inheritancemapping.genmodel"/> + </extension> + + <extension point="org.eclipse.emf.ecore.extension_parser"> + <!-- @generated inheritancemapping --> + <parser + type="inheritancemapping" + class="org.eclipse.emf.teneo.samples.emf.annotations.inheritancemapping.util.InheritancemappingResourceFactoryImpl"/> + </extension> </plugin> diff --git a/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/Price.java b/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/Price.java index 8198d5cbf..182fc00e9 100755 --- a/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/Price.java +++ b/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/Price.java @@ -24,7 +24,7 @@ import org.eclipse.emf.ecore.EObject; * </p> * * @see org.eclipse.emf.teneo.samples.emf.annotations.inheritancemapping.InheritancemappingPackage#getPrice() - * @model annotation="teneo.jpa appinfo='\n\t\t\t\t@Table(name=\"myprice\")\n\t\t\t\t@Inheritance(strategy=SINGLE_TABLE)\n\t\t\t\t@DiscriminatorColumn(name=\"DISCRIMINATOR\", discriminatorType=STRING, column=@Column(index=\"discrIndex,ohterindex\", length=120))\n\t\t\t\t@DiscriminatorValue(\"myPrice\")\n\t\t\t'" + * @model annotation="teneo.jpa appinfo='\t\t\t\t@Table(name=\"myprice\")\n\t\t\t\t@Inheritance(strategy=SINGLE_TABLE)\n\t\t\t\t@DiscriminatorColumn(name=\"DISCRIMINATOR\", discriminatorType=STRING, columnDefinition=\"character varying (100) \", column=@Column(index=\"discrIndex,ohterindex\", length=120))\n\t\t\t\t@DiscriminatorValue(\"myPrice\")\n\t\t\t'" * extendedMetaData="name='Price' kind='elementOnly'" * @generated */ diff --git a/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/impl/InheritancemappingFactoryImpl.java b/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/impl/InheritancemappingFactoryImpl.java index 5c6199c66..a2b899918 100755 --- a/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/impl/InheritancemappingFactoryImpl.java +++ b/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/impl/InheritancemappingFactoryImpl.java @@ -39,7 +39,7 @@ public class InheritancemappingFactoryImpl extends EFactoryImpl implements Inher */ public static InheritancemappingFactory init() { try { - InheritancemappingFactory theInheritancemappingFactory = (InheritancemappingFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.eclipse.org/emf/teneo/samples/emf/annotations/inheritancemapping"); + InheritancemappingFactory theInheritancemappingFactory = (InheritancemappingFactory)EPackage.Registry.INSTANCE.getEFactory(InheritancemappingPackage.eNS_URI); if (theInheritancemappingFactory != null) { return theInheritancemappingFactory; } diff --git a/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/impl/InheritancemappingPackageImpl.java b/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/impl/InheritancemappingPackageImpl.java index 054579e7e..cb32747db 100755 --- a/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/impl/InheritancemappingPackageImpl.java +++ b/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/impl/InheritancemappingPackageImpl.java @@ -711,7 +711,7 @@ public class InheritancemappingPackageImpl extends EPackageImpl implements Inher (priceEClass, source, new String[] { - "appinfo", "\n\t\t\t\t@Table(name=\"myprice\")\n\t\t\t\t@Inheritance(strategy=SINGLE_TABLE)\n\t\t\t\t@DiscriminatorColumn(name=\"DISCRIMINATOR\", discriminatorType=STRING, column=@Column(index=\"discrIndex,ohterindex\", length=120))\n\t\t\t\t@DiscriminatorValue(\"myPrice\")\n\t\t\t" + "appinfo", "\t\t\t\t@Table(name=\"myprice\")\n\t\t\t\t@Inheritance(strategy=SINGLE_TABLE)\n\t\t\t\t@DiscriminatorColumn(name=\"DISCRIMINATOR\", discriminatorType=STRING, columnDefinition=\"character varying (100) \", column=@Column(index=\"discrIndex,ohterindex\", length=120))\n\t\t\t\t@DiscriminatorValue(\"myPrice\")\n\t\t\t" }); addAnnotation (usAddressEClass, diff --git a/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/model/inheritancemapping.ecore b/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/model/inheritancemapping.ecore index 47178a467..3c5dcdc47 100755 --- a/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/model/inheritancemapping.ecore +++ b/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/model/inheritancemapping.ecore @@ -1,8 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<ecore:EPackage xmi:version="2.0" - xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="inheritancemapping" - nsURI="http://www.eclipse.org/emf/teneo/samples/emf/annotations/inheritancemapping" +<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="inheritancemapping" nsURI="http://www.eclipse.org/emf/teneo/samples/emf/annotations/inheritancemapping" nsPrefix="inheritancemapping"> <eClassifiers xsi:type="ecore:EClass" name="Address" abstract="true"> <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData"> @@ -99,7 +97,7 @@ </eClassifiers> <eClassifiers xsi:type="ecore:EClass" name="Price"> <eAnnotations source="teneo.jpa"> - <details key="appinfo" value="
				@Table(name="myprice")
				@Inheritance(strategy=SINGLE_TABLE)
				@DiscriminatorColumn(name="DISCRIMINATOR", discriminatorType=STRING, column=@Column(index="discrIndex,ohterindex", length=120))
				@DiscriminatorValue("myPrice")
			"/> + <details key="appinfo" value="				@Table(name="myprice")
				@Inheritance(strategy=SINGLE_TABLE)
				@DiscriminatorColumn(name="DISCRIMINATOR", discriminatorType=STRING, columnDefinition="character varying (100) ", column=@Column(index="discrIndex,ohterindex", length=120))
				@DiscriminatorValue("myPrice")
			"/> </eAnnotations> <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData"> <details key="name" value="Price"/> diff --git a/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/model/inheritancemapping.genmodel b/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/model/inheritancemapping.genmodel index 6b6edb917..e9061e2b5 100755 --- a/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/model/inheritancemapping.genmodel +++ b/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/model/inheritancemapping.genmodel @@ -1,9 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<genmodel:GenModel xmi:version="2.0" - xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" - xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.eclipse.emf.teneo.samples/src" - modelPluginID="org.eclipse.emf.teneo.samples" modelName="inheritancemapping" importerID="org.eclipse.emf.importer.ecore" - complianceLevel="5.0"> +<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" + xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.eclipse.emf.teneo.samples/src" modelPluginID="org.eclipse.emf.teneo.samples" + modelName="inheritancemapping" importerID="org.eclipse.emf.importer.ecore" complianceLevel="5.0"> <foreignModel>inheritancemapping.ecore</foreignModel> <genPackages prefix="Inheritancemapping" basePackage="org.eclipse.emf.teneo.samples.emf.annotations" resource="XML" disposableProviderFactory="true" ecorePackage="inheritancemapping.ecore#/"> diff --git a/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/util/InheritancemappingSwitch.java b/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/util/InheritancemappingSwitch.java index 0e3485da5..63dcd9a69 100755 --- a/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/util/InheritancemappingSwitch.java +++ b/tests/org.eclipse.emf.teneo.samples/src/org/eclipse/emf/teneo/samples/emf/annotations/inheritancemapping/util/InheritancemappingSwitch.java @@ -11,6 +11,8 @@ import java.util.List; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.util.Switch; import org.eclipse.emf.teneo.samples.emf.annotations.inheritancemapping.*; /** @@ -26,7 +28,7 @@ import org.eclipse.emf.teneo.samples.emf.annotations.inheritancemapping.*; * @see org.eclipse.emf.teneo.samples.emf.annotations.inheritancemapping.InheritancemappingPackage * @generated */ -public class InheritancemappingSwitch<T> { +public class InheritancemappingSwitch<T> extends Switch<T> { /** * The cached model package * <!-- begin-user-doc --> @@ -48,34 +50,16 @@ public class InheritancemappingSwitch<T> { } /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. + * Checks whether this is a switch for the given package. * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @return the first non-null result returned by a <code>caseXXX</code> call. + * @parameter ePackage the package in question. + * @return whether this is a switch for the given package. * @generated */ - public T doSwitch(EObject theEObject) { - return doSwitch(theEObject.eClass(), theEObject); - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - protected T doSwitch(EClass theEClass, EObject theEObject) { - if (theEClass.eContainer() == modelPackage) { - return doSwitch(theEClass.getClassifierID(), theEObject); - } - else { - List<EClass> eSuperTypes = theEClass.getESuperTypes(); - return - eSuperTypes.isEmpty() ? - defaultCase(theEObject) : - doSwitch(eSuperTypes.get(0), theEObject); - } + @Override + protected boolean isSwitchFor(EPackage ePackage) { + return ePackage == modelPackage; } /** @@ -85,6 +69,7 @@ public class InheritancemappingSwitch<T> { * @return the first non-null result returned by a <code>caseXXX</code> call. * @generated */ + @Override protected T doSwitch(int classifierID, EObject theEObject) { switch (classifierID) { case InheritancemappingPackage.ADDRESS: { @@ -383,6 +368,7 @@ public class InheritancemappingSwitch<T> { * @see #doSwitch(org.eclipse.emf.ecore.EObject) * @generated */ + @Override public T defaultCase(EObject object) { return null; } |