Skip to main content



      Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Using char with non-default size causes problems
[Teneo] Using char with non-default size causes problems [message #1184790] Wed, 13 November 2013 12:49 Go to next message
Eclipse UserFriend
Hello,

I have a model which contains two EClass. EClass A refers to EClass B.
A has a string attribute as key with the annotation:
@Column(columnDefinition="CHAR(64)")


B has a non-containment reference on A.
Using this model with MySQL works and the reference is generated correctly.

Oracle 11c can't create the constraint (ORA-02267):
alter table "B" add constraint b_a foreign key ("a_a_key") references "A"


It creates the column a_a_key as VARCHAR2(255 CHAR) instead of CHAR(64 BYTES).
I have tried to use the column annotation from above, but it doesn't work.

Can anyone help me?
It seems to be a teneo specific issue isn't it?
Re: [Teneo] Using char with non-default size causes problems [message #1185039 is a reply to message #1184790] Wed, 13 November 2013 16:34 Go to previous messageGo to next message
Eclipse UserFriend
Hi John,
Which Teneo version are you using? I solved a columndefinition issue earlier this year, but it was related to joincolumns.

gr. Martin

On 11/13/2013 06:49 PM, John M. wrote:
> Hello,
>
> I have a model which contains two EClass. EClass A refers to EClass B.
> A has a string attribute as key with the annotation:
> @Column(columnDefinition="CHAR(64)")
>
> B has a non-containment reference on A.
> Using this model with MySQL works and the reference is generated correctly.
>
> Oracle 11c can't create the constraint (ORA-02267):
> alter table "B" add constraint b_a foreign key ("a_a_key") references "A"
>
> It creates the column a_a_key as VARCHAR2(255 CHAR) instead of CHAR(64 BYTES).
> I have tried to use the column annotation from above, but it doesn't work.
>
> Can anyone help me?
> It seems to be a teneo specific issue isn't it?


--

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: [Teneo] Using char with non-default size causes problems [message #1185952 is a reply to message #1184790] Thu, 14 November 2013 06:24 Go to previous messageGo to next message
Eclipse UserFriend
Hello Martin,

I am using EMF 2.9.1-v20130827-0309 and Teneo 2.0.1-v201310012125.
Re: [Teneo] Using char with non-default size causes problems [message #1186187 is a reply to message #1185952] Thu, 14 November 2013 09:38 Go to previous messageGo to next message
Eclipse UserFriend
Hi John,
Can you print the relevant part of the hbm mapping here? You can get it from the datastore.getMappingXML method.
So in mysql you get the correct char-64?

gr. Martin

On 11/14/2013 12:24 PM, John M. wrote:
> Hello Martin,
>
> I am using EMF 2.9.1-v20130827-0309 and Teneo 2.0.1-v201310012125.


--

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: [Teneo] Using char with non-default size causes problems [message #1186214 is a reply to message #1184790] Thu, 14 November 2013 09:56 Go to previous messageGo to next message
Eclipse UserFriend
Hello Martin,

I will post the mapping later.
MySQL has no problems with different data types, CHAR(64) and VARCHAR(255). But in general it isn't correct.
Re: [Teneo] Using char with non-default size causes problems [message #1187675 is a reply to message #1186214] Fri, 15 November 2013 03:10 Go to previous messageGo to next message
Eclipse UserFriend
Hi John,
I tried myself but afaics the columndefinition is correctly transferred to hbm:
the annotation:
(in this case in a xsd)
<xsd:element name="stringVal" nillable="true"
type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">
@Column(name="stringVal",columnDefinition = "CHARACTER(64) NOT NULL")
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

the hbm:
<property name="stringVal" lazy="false" insert="true" update="true" not-null="false" unique="false"
type="java.lang.String">
<column not-null="false" unique="false" name="`STRINGVAL`" sql-type="CHARACTER(64) NOT NULL"/>
</property>

gr. Martin

On 11/14/2013 03:56 PM, John M. wrote:
> Hello Martin,
>
> I will post the mapping later.
> MySQL has no problems with different data types, CHAR(64) and VARCHAR(255). But in general it isn't correct.


--

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: [Teneo] Using char with non-default size causes problems [message #1187708 is a reply to message #1184790] Fri, 15 November 2013 03:34 Go to previous messageGo to next message
Eclipse UserFriend
Hello Martin,

the "normal" column works, but it doesn't work in a relation.
<class name="AImpl" entity-name="A" abstract="false" lazy="false" discriminator-value="A" table="`a`">
	<meta attribute="eclassName" inherit="false">A</meta>
	<id name="key" type="java.lang.String">
		<column not-null="true" unique="false" name="`key`" sql-type="CHAR(64)"/>
	</id>
</class>
<class name="BImpl" entity-name="B" abstract="false" lazy="false" discriminator-value="B" table="`b`">
	<meta attribute="eclassName" inherit="false">B</meta>
	<id type="long" name="e_id" column="e_id" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler">
		<meta attribute="syntheticId" inherit="false">true</meta>
		<generator class="native"/>
	</id>
	<many-to-one name="a" entity-name="A" lazy="false" foreign-key="b_a" insert="true" update="true" not-null="false">
		<column not-null="false" unique="false" name="`a_a_key`"/>
	</many-to-one>
</class>
Re: [Teneo] Using char with non-default size causes problems [message #1187781 is a reply to message #1187708] Fri, 15 November 2013 04:20 Go to previous messageGo to next message
Eclipse UserFriend
Hi John,
For an association you need to use the JoinColumn annotation (instead of Column), did you try that?

gr. Martin

On 11/15/2013 09:34 AM, John M. wrote:
> Hello Martin,
>
> the "normal" column works, but it doesn't work in a relation.
>
> <class name="AImpl" entity-name="A" abstract="false" lazy="false" discriminator-value="A" table="`a`">
> <meta attribute="eclassName" inherit="false">A</meta>
> <id name="key" type="java.lang.String">
> <column not-null="true" unique="false" name="`key`" sql-type="CHAR(64)"/>
> </id>
> </class>
> <class name="BImpl" entity-name="B" abstract="false" lazy="false" discriminator-value="B" table="`b`">
> <meta attribute="eclassName" inherit="false">B</meta>
> <id type="long" name="e_id" column="e_id"
> access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler">
> <meta attribute="syntheticId" inherit="false">true</meta>
> <generator class="native"/>
> </id>
> <many-to-one name="a" entity-name="A" lazy="false" foreign-key="b_a" insert="true" update="true" not-null="false">
> <column not-null="false" unique="false" name="`a_a_key`"/>
> </many-to-one>
> </class>
>


--

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: [Teneo] Using char with non-default size causes problems [message #1187884 is a reply to message #1187781] Fri, 15 November 2013 05:27 Go to previous messageGo to next message
Eclipse UserFriend
Hello Martin,

I didn't try it before. When I add that annotation it works.
But it means that I need to maintain the size at two different points, right?

I think it isn't the "best" way. Perhaps it would be possible to detect the datatype of the referenced column in class A automatically and adjust the foreign key column in class B.
Re: [Teneo] Using char with non-default size causes problems [message #1188312 is a reply to message #1187884] Fri, 15 November 2013 10:14 Go to previous messageGo to next message
Eclipse UserFriend
Hi John,
Yes I agree that this would be best, but it is an ORM responsibility to do that imho.

I am surprised that the ORM does not do this automatically, maybe it is because the ColumnDefinition allows much
flexibility which is difficult to parse (like not null, which you maybe not want for the foreign key column).

gr. Martin

On 11/15/2013 11:27 AM, John M. wrote:
> Hello Martin,
>
> I didn't try it before. When I add that annotation it works.
> But it means that I need to maintain the size at two different points, right?
>
> I think it isn't the "best" way. Perhaps it would be possible to detect the datatype of the referenced column in class A
> automatically and adjust the foreign key column in class B.


--

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: [Teneo] Using char with non-default size causes problems [message #1194457 is a reply to message #1184790] Mon, 18 November 2013 09:16 Go to previous messageGo to next message
Eclipse UserFriend
Hello Martin,

yes could be possible, but I think you can restrict as ORM developer, which parameters are transferred. Smile
For example the datatype would be important.
Re: [Teneo] Using char with non-default size causes problems [message #1194568 is a reply to message #1194457] Mon, 18 November 2013 10:28 Go to previous messageGo to next message
Eclipse UserFriend
Hey John,
Hmm, not sure I fully follow you, it would mean parsing the columndefinition I think, but sounds like a great feature
for sponsored development ;-) or a contribution! :-)

gr. Martin

On 11/18/2013 03:16 PM, John M. wrote:
> Hello Martin,
>
> yes could be possible, but I think you can restrict as ORM developer, which parameters are transferred. :)
> For example the datatype would be important.


--

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: [Teneo] Using char with non-default size causes problems [message #1194632 is a reply to message #1194568] Mon, 18 November 2013 11:10 Go to previous messageGo to next message
Eclipse UserFriend
Hello Martin,

but it would be better to implement such a function in Hibernate wouldn't it?
The idea is just to look for specific things which are interesting for the join column like data type and ignore properties like "not null" and similar mentioned above.
Re: [Teneo] Using char with non-default size causes problems [message #1194696 is a reply to message #1194632] Mon, 18 November 2013 11:47 Go to previous message
Eclipse UserFriend
Yes it would be, but I guess the columndefinition can be anything and can differ on the type of database you use, so it
would be dangeruous for the ORM to automatically derive column properties/types from that.

But in any case it doesn't work as of now :-)

gr. Martin

On 11/18/2013 05:10 PM, John M. wrote:
> Hello Martin,
>
> but it would be better to implement such a function in Hibernate wouldn't it?
> The idea is just to look for specific things which are interesting for the join column like data type and ignore
> properties like "not null" and similar mentioned above.


--

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
Previous Topic:EMFStore or (and) CDO
Next Topic:[Teneo] Override teneo.jpa annotation while runtime
Goto Forum:
  


Current Time: Mon Jul 14 02:56:36 EDT 2025

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

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

Back to the top