|
Re: Order of @Type and @JoinTable can break hibernate mapping [message #986717 is a reply to message #986666] |
Wed, 21 November 2012 12:37 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Rob,
To me it seems like a real bug.. Can you enter a bugzilla for it?
gr. Martin
On 11/21/2012 11:35 AM, Rob Mising name wrote:
> Hi Martin, All,
>
> I'd really appreciate some more assistance. I think I have found some strange behaviour based on the order of the @Type
> and @JoinTable in annotations. 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="bds">
> <details key="isCase" value="true"/>
> </eAnnotations>
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@Table(name="MYTEST_CASE1")
> @DiscriminatorValue("com.example.mytest.Case1")"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="attribute1" unique="false"
> upperBound="-1" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//DateTime">
> <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="@JoinTable(name="MYTEST_CASE1_ATTRIBUTE1")
> @Type(type="com.rob.bds.core.hibernate.XMLGCDateTime")
> @Column(name="ATTRIBUTE1")"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="bdsId" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//ELongObject">
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@GeneratedValue(strategy="AUTO")
> @Id
> @Column(name="BDS_ID")"/>
> </eAnnotations>
> <eAnnotations source="bds">
> <details key="isId" value="true"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="bdsVersion" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//ELongObject">
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@Version
> @Column(name="BDS_VERSION")"/>
> </eAnnotations>
> <eAnnotations source="bds">
> <details key="isVersion" value="true"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
>
>
> Note the order of the teneo.jpa:
>
> Quote:
>> @JoinTable(name="MYTEST_CASE1_ATTRIBUTE1")
>> @Type(type="com.rob.bds.core.hibernate.XMLGCDateTime")
>> @Column(name="ATTRIBUTE1")
>
>
> Then the hibrnate mapping generated is as expected:
>
> <hibernate-mapping auto-import="false">
> <class entity-name="mytest.Case1" abstract="false" lazy="false" discriminator-value="com.example.mytest.Case1"
> table="`BDS_1_MYTEST_CASE1`">
> <meta attribute="eclassName">Case1</meta>
> <meta attribute="epackage">http://example.com/mytest</meta>
> <id name="bdsId" type="java.lang.Long">
> <column not-null="false" unique="false" name="`BDS_ID`"/>
> <generator class="native"/>
> </id>
> <discriminator column="`DTYPE`" type="string"/>
> <version name="bdsVersion" type="java.lang.Long">
> <column not-null="false" unique="false" name="`BDS_VERSION`"/>
> </version>
> <list name="attribute1" table="`BDS_1_MYTEST_CASE1ATTRIBUTE1`" lazy="true" cascade="all,delete-orphan">
> <key update="true">
> <column name="`CASE1_ATTRIBUTE1_BDSID`" not-null="true" unique="false"/>
> </key>
> <list-index column="`CASE1_ATTRIBUTE1_IDX`"/>
> <element type="com.rob.bds.core.hibernate.XMLGCDateTime" not-null="false" unique="false">
> <column not-null="false" unique="false" name="`ATTRIBUTE1`"/>
> </element>
> </list>
> </class>
> </hibernate-mapping>
>
>
> However if the ecore changes to:
>
> <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="bds">
> <details key="isCase" value="true"/>
> </eAnnotations>
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@Table(name="MYTEST_CASE1")
> @DiscriminatorValue("com.example.mytest.Case1")"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="attribute1" unique="false"
> upperBound="-1" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//DateTime">
> <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="@Type(type="com.rob.bds.core.hibernate.XMLGCDateTime")
> @JoinTable(name="MYTEST_CASE1_ATTRIBUTE1")
> @Column(name="ATTRIBUTE1")"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="bdsId" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//ELongObject">
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@GeneratedValue(strategy="AUTO")
> @Id
> @Column(name="BDS_ID")"/>
> </eAnnotations>
> <eAnnotations source="bds">
> <details key="isId" value="true"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="bdsVersion" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//ELongObject">
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@Version
> @Column(name="BDS_VERSION")"/>
> </eAnnotations>
> <eAnnotations source="bds">
> <details key="isVersion" value="true"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
>
>
> Again note the change in order of the teneo.jpa:
>
> Quote:
>> @Type(type="com.rob.bds.core.hibernate.XMLGCDateTime")
>> @JoinTable(name="MYTEST_CASE1_ATTRIBUTE1")
>> @Column(name="ATTRIBUTE1")
>
>
> Then the hibrnate mapping generated is not as I would expect:
>
> <hibernate-mapping auto-import="false">
> <class entity-name="mytest.Case1" abstract="false" lazy="false" discriminator-value="com.example.mytest.Case1"
> table="`BDS_1_MYTEST_CASE1`">
> <meta attribute="eclassName">Case1</meta>
> <meta attribute="epackage">http://example.com/mytest</meta>
> <id name="bdsId" type="java.lang.Long">
> <column not-null="false" unique="false" name="`BDS_ID`"/>
> <generator class="native"/>
> </id>
> <discriminator column="`DTYPE`" type="string"/>
> <version name="bdsVersion" type="java.lang.Long">
> <column not-null="false" unique="false" name="`BDS_VERSION`"/>
> </version>
> <list name="attribute1" table="`MYTEST_CASE1_ATTRIBUTE1`" lazy="true" cascade="all,delete-orphan">
> <key update="true">
> <column name="`CASE1_ATTRIBUTE1_BDSID`" not-null="true" unique="false"/>
> </key>
> <list-index column="`CASE1_ATTRIBUTE1_IDX`"/>
> <element type="BDS_1_MYTEST_CASE1ATTRIBUTE1" not-null="false" unique="false">
> <column not-null="false" unique="false" name="`ATTRIBUTE1`"/>
> </element>
> </list>
> </class>
> </hibernate-mapping>
>
>
> The line:
>
> Quote:
>> <element type="BDS_1_MYTEST_CASE1ATTRIBUTE1" not-null="false" unique="false">
>
>
> Has put in a very strange type!
>
> Any ideas?
>
> 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.03966 seconds