[Teneo] EntityInterfaceNameStrategy not setting Enumerations as expected [message #1007549] |
Wed, 06 February 2013 11:54 |
Rob Mising name Messages: 118 Registered: July 2010 |
Senior Member |
|
|
Hi Martin,
I noticed in the FAQ, that there is an additional Entity Naming Strategy called "EntityInterfaceNameStrategy":
http://wiki.eclipse.org/Teneo/Hibernate/FAQ#Unknown_Entity
I was surprised it was not listed in the Docs:
http://wiki.eclipse.org/Teneo/Hibernate/Extensions#EntityNameStrategy_ExtensionPoint_.28org.eclipse.emf.teneo.mapping.strategy.EntityNameStrategy.29
This seemed to be in line with the sort of entity naming strategy that I was looking for, however it does not seem to cover the case of the Enumerations, so if I have an eCore as follows:
<eClassifiers xsi:type="ecore:EClass" name="Case1">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="Case1"/>
<details key="kind" value="elementOnly"/>
</eAnnotations>
<eAnnotations source="teneo.jpa">
<details key="value" value="@Table(name="ENUMTEST_CASE1")
@DiscriminatorValue("com.example.enumtest.Case1")"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="attribute1" eType="//Enumeration1Object">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
<details key="name" value="attribute1"/>
</eAnnotations>
<eAnnotations source="teneo.jpa">
<details key="value" value="@Column(name="ATTRIBUTE1")"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="bdsId">
<eAnnotations source="teneo.jpa">
<details key="value" value="@Id
@Column(name="BDS_ID", nullable="false")"/>
</eAnnotations>
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//ELongObject"/>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="bdsVersion">
<eAnnotations source="teneo.jpa">
<details key="value" value="@Column(name="BDS_VERSION")
@Version"/>
</eAnnotations>
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//ELongObject"/>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EEnum" name="Enumeration1">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="Enumeration1"/>
</eAnnotations>
<eLiterals name="ENUMLIT1"/>
<eLiterals name="ENUMLIT2" value="1"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EDataType" name="Enumeration1ElementType" instanceClassName="org.eclipse.emf.common.util.Enumerator">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="Enumeration1Element_._type"/>
<details key="baseType" value="Enumeration1"/>
</eAnnotations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EDataType" name="Enumeration1Object" instanceClassName="org.eclipse.emf.common.util.Enumerator">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="Enumeration1:Object"/>
<details key="baseType" value="Enumeration1"/>
</eAnnotations>
</eClassifiers>
Then it will generate a Hibernate mapping as follows:
<hibernate-mapping auto-import="false">
<typedef name="enumtest.Enumeration1ElementType" class="org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserType">
<param name="epackage">http://example.com/enumtest</param>
<param name="edatatype">Enumeration1ElementType</param>
</typedef>
<typedef name="enumtest.Enumeration1Object" class="org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserType">
<param name="epackage">http://example.com/enumtest</param>
<param name="edatatype">Enumeration1Object</param>
</typedef>
<class name="com.example.enumtest.impl.Case1Impl" entity-name="com.example.enumtest.Case1" abstract="false" lazy="false" discriminator-value="com.example.enumtest.Case1" table="`BDS_1_ENUMTEST_CASE1`">
<meta attribute="eclassName">Case1</meta>
<meta attribute="epackage">http://example.com/enumtest</meta>
<id name="bdsId" type="java.lang.Long">
<column not-null="true" unique="false" name="`BDS_ID`"/>
</id>
<discriminator column="`DTYPE`" type="string"/>
<version name="bdsVersion" type="java.lang.Long">
<column not-null="false" unique="false" name="`BDS_VERSION`"/>
</version>
<property name="attribute1" lazy="false" insert="true" update="true" not-null="false" unique="false" type="enumtest.Enumeration1Object">
<column not-null="false" unique="false" name="`ATTRIBUTE1`"/>
</property>
</class>
</hibernate-mapping>
It appears to set the Case1 entity-name [and name] as expected (com.example.enumtest.Case1), however the enumerations just get name="enumtest.Enumeration1ElementType" - where I was assuming it would be fully qualified as well?
Was this the intended behaviour - I wasn't sure if I was missing something.
Thanks
Rob
[Updated on: Wed, 06 February 2013 12:28] Report message to a moderator
|
|
|
Re: [Teneo] EntityInterfaceNameStrategy no setting Enumerations correctly [message #1007734 is a reply to message #1007549] |
Thu, 07 February 2013 11:01 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Rob,
Hmm, yes in this case, the enum is not an entity but an internal hbm-type definition. So it is something used within the
hbm-mapping and not something normally used outside of it (like in a hql query). Is it a showstopper or just something
you noticed?
gr. Martin
On 02/06/2013 12:54 PM, Rob Mising name wrote:
> Hi Martin,
>
> I noticed in the FAQ, that there is an additional Entity Naming Strategy called "EntityInterfaceNameStrategy":
>
> http://wiki.eclipse.org/Teneo/Hibernate/FAQ#Unknown_Entity
>
> I was surprised it was not listed in the Docs:
>
> http://wiki.eclipse.org/Teneo/Hibernate/Extensions#EntityNameStrategy_ExtensionPoint_.28org.eclipse.emf.teneo.mapping.strategy.EntityNameStrategy.29
>
>
> This seemed to be in line with the sort of entity naming strategy that I was looking for, however it does not seem to
> cover the case of the Enumerations, so if I have an eCore as follows:
>
> <eClassifiers xsi:type="ecore:EClass" name="Case1">
> <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="Case1"/>
> <details key="kind" value="elementOnly"/>
> </eAnnotations>
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@Table(name="ENUMTEST_CASE1")
> @DiscriminatorValue("com.example.enumtest.Case1")"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="attribute1" eType="//Enumeration1Object">
> <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="attribute1"/>
> </eAnnotations>
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@Column(name="ATTRIBUTE1")"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="bdsId">
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@Id
> @Column(name="BDS_ID", nullable="false")"/>
> </eAnnotations>
> <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//ELongObject"/>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="bdsVersion">
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@Column(name="BDS_VERSION")
> @Version"/>
> </eAnnotations>
> <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//ELongObject"/>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EEnum" name="Enumeration1">
> <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="Enumeration1"/>
> </eAnnotations>
> <eLiterals name="ENUMLIT1"/>
> <eLiterals name="ENUMLIT2" value="1"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EDataType" name="Enumeration1ElementType"
> instanceClassName="org.eclipse.emf.common.util.Enumerator">
> <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="Enumeration1Element_._type"/>
> <details key="baseType" value="Enumeration1"/>
> </eAnnotations>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EDataType" name="Enumeration1Object"
> instanceClassName="org.eclipse.emf.common.util.Enumerator">
> <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="Enumeration1:Object"/>
> <details key="baseType" value="Enumeration1"/>
> </eAnnotations>
> </eClassifiers>
>
> Then it will generate a Hibernate mapping as follows:
>
> <hibernate-mapping auto-import="false">
> <typedef name="enumtest.Enumeration1ElementType"
> class="org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserType">
> <param name="epackage">http://example.com/enumtest</param>
> <param name="edatatype">Enumeration1ElementType</param>
> </typedef>
> <typedef name="enumtest.Enumeration1Object" class="org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserType">
> <param name="epackage">http://example.com/enumtest</param>
> <param name="edatatype">Enumeration1Object</param>
> </typedef>
> <class name="com.example.enumtest.impl.Case1Impl" entity-name="com.example.enumtest.Case1" abstract="false"
> lazy="false" discriminator-value="com.example.enumtest.Case1" table="`BDS_1_ENUMTEST_CASE1`">
> <meta attribute="eclassName">Case1</meta>
> <meta attribute="epackage">http://example.com/enumtest</meta>
> <id name="bdsId" type="java.lang.Long">
> <column not-null="true" unique="false" name="`BDS_ID`"/>
> </id>
> <discriminator column="`DTYPE`" type="string"/>
> <version name="bdsVersion" type="java.lang.Long">
> <column not-null="false" unique="false" name="`BDS_VERSION`"/>
> </version>
> <property name="attribute1" lazy="false" insert="true" update="true" not-null="false" unique="false"
> type="enumtest.Enumeration1Object">
> <column not-null="false" unique="false" name="`ATTRIBUTE1`"/>
> </property>
> </class>
> </hibernate-mapping>
>
> It appears to set the Case1 entity-name [and name] as expected (com.example.enumtest.Case1), however the enumerations
> just get name="enumtest.Enumeration1ElementType" - where I was assuming it would be fully qualified as well?
>
> Was this the intended behaviour - I wasn't sure if I was missing something.
>
> Thanks
>
> Rob
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02908 seconds