Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » @Lob Causing incorrect Hibrenate mapping(upperBound="-1" is ignored when @Lob is used)
@Lob Causing incorrect Hibrenate mapping [message #985642] Thu, 15 November 2012 15:15 Go to next message
Rob Mising name is currently offline Rob Mising nameFriend
Messages: 118
Registered: July 2010
Senior Member
With an eCore that looks 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;ROBTEST_CASE1&quot;)&#xA;@DiscriminatorValue(&quot;com.example.robtest.Case1&quot;)"/>
    </eAnnotations>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="stringLob" unique="false" upperBound="-1">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="element"/>
        <details key="name" value="stringLob"/>
      </eAnnotations>
      <eAnnotations source="teneo.jpa">
        <details key="value" value="@Lob&#xA;@Column(name=&quot;STRINGLOB&quot;, length=&quot;1048576&quot;)"/>
      </eAnnotations>
      <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2003/XMLType#//String"/>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="bdsId">
      <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>
      <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="@Version&#xA;@Column(name=&quot;BDS_VERSION&quot;)"/>
      </eAnnotations>
      <eAnnotations source="bds">
        <details key="isVersion" value="true"/>
      </eAnnotations>
      <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//ELongObject"/>
    </eStructuralFeatures>
  </eClassifiers>


So the "stringLob" has the following annotation:

Quote:

@Lob
@Column(name="STRINGLOB", length="1048576")


If this is used to generate a hibernate mapping it gives:

<hibernate-mapping auto-import="false">
	<class entity-name="robtest.Case1" abstract="false" lazy="false" discriminator-value="com.example.robtest.Case1" table="`BDS_1_ROBTEST_CASE1`">
		<meta attribute="eclassName">Case1</meta>
		<meta attribute="epackage">http://example.com/robtest</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>
		<property name="stringLob" lazy="false" insert="true" update="true" not-null="false" unique="false" type="text">
			<column not-null="false" unique="false" name="`STRINGLOB`" length="1048576"/>
		</property>
	</class>
</hibernate-mapping>


But because the upperBound="-1" is specified, I would have expected it to generate a list for stringLob:

<hibernate-mapping auto-import="false">
	<class entity-name="robtest.Case1" abstract="false" lazy="false" discriminator-value="com.example.robtest.Case1" table="`BDS_1_ROBTEST_CASE1`">
		<meta attribute="eclassName">Case1</meta>
		<meta attribute="epackage">http://example.com/robtest</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="stringLob" table="`BDS_1_ROBTEST_CASE1STRINGLOB`" lazy="true" cascade="all,delete-orphan">
			<key update="true">
				<column name="`CASE1_STRINGLOB_BDSID`" not-null="true" unique="false"/>
			</key>
			<list-index column="`CASE1_STRINGLOB_IDX`"/>
			<element type="java.lang.String" not-null="false" unique="false" type="text">
				<column not-null="false" unique="false" name="`STRINGLOB`" length="1048576"/>
			</element>
		</list>
		<property name="stringLob" lazy="false" insert="true" update="true" not-null="false" unique="false" type="text">
			<column not-null="false" unique="false" name="`STRINGLOB`" length="1048576"/>
		</property>
	</class>
</hibernate-mapping>


Is anyone able to assist me with this, is it a know problem, or am I doing something wrong?

Thanks

Rob


Re: @Lob Causing incorrect Hibrenate mapping [message #985903 is a reply to message #985642] Fri, 16 November 2012 15:56 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5339
Registered: July 2009
Senior Member
Hi Rob,
This is an omission in Teneo, I am solving it and will do a new build sometime today.

gr. Martin

On 11/15/2012 04:16 PM, Rob Mising name wrote:
> With an eCore that looks 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="ROBTEST_CASE1")
> @DiscriminatorValue("com.example.robtest.Case1")"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="stringLob" unique="false" upperBound="-1">
> <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="stringLob"/>
> </eAnnotations>
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@Lob
> @Column(name="STRINGLOB", length="1048576")"/>
> </eAnnotations>
> <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2003/XMLType#//String"/>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="bdsId">
> <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>
> <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="@Version
> @Column(name="BDS_VERSION")"/>
> </eAnnotations>
> <eAnnotations source="bds">
> <details key="isVersion" value="true"/>
> </eAnnotations>
> <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//ELongObject"/>
> </eStructuralFeatures>
> </eClassifiers>
>
>
> So the "stringLob" has the following annotation:
>
> Quote:
>> @Lob
>> @Column(name="STRINGLOB", length="1048576")
>
>
> If this is used to generate a hibernate mapping it gives:
>
> <hibernate-mapping auto-import="false">
> <class entity-name="robtest.Case1" abstract="false" lazy="false" discriminator-value="com.example.robtest.Case1"
> table="`BDS_1_ROBTEST_CASE1`">
> <meta attribute="eclassName">Case1</meta>
> <meta attribute="epackage">http://example.com/robtest</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>
> <property name="stringLob" lazy="false" insert="true" update="true" not-null="false" unique="false" type="text">
> <column not-null="false" unique="false" name="`STRINGLOB`" length="1048576"/>
> </property>
> </class>
> </hibernate-mapping>
>
>
> But because the upperBound="-1" is specified, I would have expected it to generate a list for stringLob:
>
> <hibernate-mapping auto-import="false">
> <class entity-name="robtest.Case1" abstract="false" lazy="false" discriminator-value="com.example.robtest.Case1"
> table="`BDS_1_ROBTEST_CASE1`">
> <meta attribute="eclassName">Case1</meta>
> <meta attribute="epackage">http://example.com/robtest</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="stringLob" table="`BDS_1_ROBTEST_CASE1STRINGLOB`" lazy="true" cascade="all,delete-orphan">
> <key update="true">
> <column name="`CASE1_STRINGLOB_BDSID`" not-null="true" unique="false"/>
> </key>
> <list-index column="`CASE1_STRINGLOB_IDX`"/>
> <element type="java.lang.String" not-null="false" unique="false" type="text">
> <column not-null="false" unique="false" name="`STRINGLOB`" length="1048576"/>
> </element>
> </list>
> <property name="stringLob" lazy="false" insert="true" update="true" not-null="false" unique="false" type="text">
> <column not-null="false" unique="false" name="`STRINGLOB`" length="1048576"/>
> </property>
> </class>
> </hibernate-mapping>
>
>
> Is anyone able to assist me with this, is it a know problem, or am I doing something wrong?
>
> 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: @Lob Causing incorrect Hibrenate mapping [message #985948 is a reply to message #985903] Fri, 16 November 2012 19:59 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5339
Registered: July 2009
Senior Member
Hi Rob,
I published a new build which should solve this.

gr. Martin

On 11/16/2012 04:56 PM, Martin Taal wrote:
> Hi Rob,
> This is an omission in Teneo, I am solving it and will do a new build sometime today.
>
> gr. Martin
>
> On 11/15/2012 04:16 PM, Rob Mising name wrote:
>> With an eCore that looks 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="ROBTEST_CASE1")
>> @DiscriminatorValue("com.example.robtest.Case1")"/>
>> </eAnnotations>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="stringLob" unique="false" upperBound="-1">
>> <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="element"/>
>> <details key="name" value="stringLob"/>
>> </eAnnotations>
>> <eAnnotations source="teneo.jpa">
>> <details key="value" value="@Lob
>> @Column(name="STRINGLOB", length="1048576")"/>
>> </eAnnotations>
>> <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2003/XMLType#//String"/>
>> </eStructuralFeatures>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="bdsId">
>> <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>
>> <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="@Version
>> @Column(name="BDS_VERSION")"/>
>> </eAnnotations>
>> <eAnnotations source="bds">
>> <details key="isVersion" value="true"/>
>> </eAnnotations>
>> <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//ELongObject"/>
>> </eStructuralFeatures>
>> </eClassifiers>
>>
>>
>> So the "stringLob" has the following annotation:
>>
>> Quote:
>>> @Lob
>>> @Column(name="STRINGLOB", length="1048576")
>>
>>
>> If this is used to generate a hibernate mapping it gives:
>>
>> <hibernate-mapping auto-import="false">
>> <class entity-name="robtest.Case1" abstract="false" lazy="false" discriminator-value="com.example.robtest.Case1"
>> table="`BDS_1_ROBTEST_CASE1`">
>> <meta attribute="eclassName">Case1</meta>
>> <meta attribute="epackage">http://example.com/robtest</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>
>> <property name="stringLob" lazy="false" insert="true" update="true" not-null="false" unique="false" type="text">
>> <column not-null="false" unique="false" name="`STRINGLOB`" length="1048576"/>
>> </property>
>> </class>
>> </hibernate-mapping>
>>
>>
>> But because the upperBound="-1" is specified, I would have expected it to generate a list for stringLob:
>>
>> <hibernate-mapping auto-import="false">
>> <class entity-name="robtest.Case1" abstract="false" lazy="false" discriminator-value="com.example.robtest.Case1"
>> table="`BDS_1_ROBTEST_CASE1`">
>> <meta attribute="eclassName">Case1</meta>
>> <meta attribute="epackage">http://example.com/robtest</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="stringLob" table="`BDS_1_ROBTEST_CASE1STRINGLOB`" lazy="true" cascade="all,delete-orphan">
>> <key update="true">
>> <column name="`CASE1_STRINGLOB_BDSID`" not-null="true" unique="false"/>
>> </key>
>> <list-index column="`CASE1_STRINGLOB_IDX`"/>
>> <element type="java.lang.String" not-null="false" unique="false" type="text">
>> <column not-null="false" unique="false" name="`STRINGLOB`" length="1048576"/>
>> </element>
>> </list>
>> <property name="stringLob" lazy="false" insert="true" update="true" not-null="false" unique="false" type="text">
>> <column not-null="false" unique="false" name="`STRINGLOB`" length="1048576"/>
>> </property>
>> </class>
>> </hibernate-mapping>
>>
>>
>> Is anyone able to assist me with this, is it a know problem, or am I doing something wrong?
>>
>> 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: @Lob Causing incorrect Hibrenate mapping [message #986166 is a reply to message #985948] Mon, 19 November 2012 09:35 Go to previous messageGo to next message
Rob Mising name is currently offline Rob Mising nameFriend
Messages: 118
Registered: July 2010
Senior Member
Thanks Martin!

That was a super quick fix.

Please would you be able to point me at the fix that you made - I'd be very interested to see what you needed to change - we are using an older version, and I'd like to see it I can find a way of incorperating your change.

Thanks

Rob
Re: @Lob Causing incorrect Hibrenate mapping [message #986176 is a reply to message #986166] Mon, 19 November 2012 10:15 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5339
Registered: July 2009
Senior Member
Hi Rob,
It is this changeset:
http://git.eclipse.org/c/teneo/org.eclipse.emf.teneo.git/commit/?id=c2589b7076d2e1cabd099fd2883bdb5416d22f01

But more specifically this change:
http://git.eclipse.org/c/teneo/org.eclipse.emf.teneo.git/diff/core/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/annotations/mapper/EFeatureAnnotator.java?id=c2589b7076d2e1cabd099fd2883bdb5416d22f01

gr. Martin


On 11/19/2012 10:35 AM, Rob Mising name wrote:
> Thanks Martin!
>
> That was a super quick fix.
>
> Please would you be able to point me at the fix that you made - I'd be very interested to see what you needed to change
> - we are using an older version, and I'd like to see it I can find a way of incorperating your change.
>
> 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: @Lob Causing incorrect Hibrenate mapping [message #986282 is a reply to message #986176] Mon, 19 November 2012 17:29 Go to previous messageGo to next message
Rob Mising name is currently offline Rob Mising nameFriend
Messages: 118
Registered: July 2010
Senior Member
Hi Martin,

Thanks for the information. I have managed to port the change in EFeatureAnnotator into some test code, and it now does indeed generate the expected mapping.

Sorry to ask a stupid question, but are all the "Audit" changes also required?

The reason I ask is that I'm having trouble in my test code persisting an EObject into the newley generated tables from the new hibernate mapping and didn't know if it was because I have only taken this one change.

Thanks

Rob
Re: @Lob Causing incorrect Hibrenate mapping [message #986287 is a reply to message #986282] Mon, 19 November 2012 18:15 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5339
Registered: July 2009
Senior Member
Hi Rob,
No the auditing changes are not related to this... Should have pushed that part in a separate commit.. The auditing
changes are for this new feature:
http://wiki.eclipse.org/Teneo/Hibernate/Auditing

gr. Martin

On 11/19/2012 06:29 PM, Rob Mising name wrote:
> Hi Martin,
>
> Thanks for the information. I have managed to port the change in EFeatureAnnotator into some test code, and it now does
> indeed generate the expected mapping.
>
> Sorry to ask a stupid question, but are all the "Audit" changes also required?
>
> The reason I ask is that I'm having trouble in my test code persisting an EObject into the newley generated tables from
> the new hibernate mapping and didn't know if it was because I have only taken this one change.
>
> 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: @Lob Causing incorrect Hibrenate mapping [message #986387 is a reply to message #986287] Tue, 20 November 2012 10:10 Go to previous message
Rob Mising name is currently offline Rob Mising nameFriend
Messages: 118
Registered: July 2010
Senior Member
Thanks for your help Martin.

I've now got it all working like a charm!

Thanks, Rob
Previous Topic:[EMF Compare] GMF comparison project plan
Next Topic:[CDO] CDOResource name equal
Goto Forum:
  


Current Time: Wed Nov 26 13:17:21 GMT 2014

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

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