Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Order of @Type and @JoinTable can break hibernate mapping(Putting @Type before @JoinTable will break mapping)
Order of @Type and @JoinTable can break hibernate mapping [message #986666] Wed, 21 November 2012 10:35 Go to next message
Rob Mising name is currently offline Rob Mising nameFriend
Messages: 118
Registered: July 2010
Senior Member
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=&quot;MYTEST_CASE1&quot;)&#xA;@DiscriminatorValue(&quot;com.example.mytest.Case1&quot;)"/>
    </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=&quot;MYTEST_CASE1_ATTRIBUTE1&quot;)&#xD;&#xA;@Type(type=&quot;com.rob.bds.core.hibernate.XMLGCDateTime&quot;)&#xD;&#xA;@Column(name=&quot;ATTRIBUTE1&quot;)"/>
      </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=&quot;AUTO&quot;)&#xA;@Id&#xA;@Column(name=&quot;BDS_ID&quot;)"/>
      </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&#xA;@Column(name=&quot;BDS_VERSION&quot;)"/>
      </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=&quot;MYTEST_CASE1&quot;)&#xA;@DiscriminatorValue(&quot;com.example.mytest.Case1&quot;)"/>
    </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=&quot;com.rob.bds.core.hibernate.XMLGCDateTime&quot;)&#xA;@JoinTable(name=&quot;MYTEST_CASE1_ATTRIBUTE1&quot;)&#xA;@Column(name=&quot;ATTRIBUTE1&quot;)"/>
      </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=&quot;AUTO&quot;)&#xA;@Id&#xA;@Column(name=&quot;BDS_ID&quot;)"/>
      </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&#xA;@Column(name=&quot;BDS_VERSION&quot;)"/>
      </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
Re: Order of @Type and @JoinTable can break hibernate mapping [message #986717 is a reply to message #986666] Wed, 21 November 2012 12:37 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5340
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
Re: Order of @Type and @JoinTable can break hibernate mapping [message #986776 is a reply to message #986717] Wed, 21 November 2012 15:27 Go to previous message
Rob Mising name is currently offline Rob Mising nameFriend
Messages: 118
Registered: July 2010
Senior Member
Thanks Martin, I have raised:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=394798

Thanks

Rob
Previous Topic:Target Definition and Unknown DB Adaptor: mysql
Next Topic:UUID eattribute conflicts in ECoreUtil.copy
Goto Forum:
  


Current Time: Sat Dec 20 18:40:58 GMT 2014

Powered by FUDForum. Page generated in 0.01787 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software