Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Teneo] String fields mapping (problem with ntext/varchar)(How do I map Strings of the different lengths to the proper types in DB)
[Teneo] String fields mapping (problem with ntext/varchar) [message #654109] Mon, 14 February 2011 09:08 Go to next message
Lukas Zaruba is currently offline Lukas ZarubaFriend
Messages: 8
Registered: January 2010
Junior Member
Hi everyone,
I ran into several difficulties with annotations of String fields. I tried to use JPA annotation to pass information to the persistent layer, and I managed to achieve some success, but now I am stucked with following problem.

I have String field which can exceed 4000 chars. I tried to map this field with the following annotation:
source = 'teneo.jpa',
key = 'value',
value = '@Lob
@Column(length=65535)'
As a result, in MSSQL 2008 and MySQL 5.1 it was mapped as text and longvarchar respectively.

Which actually doesn't work for me, because it doesn't allow HQL Queries like select distinct a from A a left join .... because text field cannot be used in distinct and apparently previous query is translated into SQL in some way that the String field figures in the select.

I tried changing the type of column in the DB (MSSQL 2000 - not possible to switch to the newer version yet) to varchar(8000) which would be sufficient, but now I am stucked with following error: "Caused by: java.sql.SQLException: Disallowed implicit conversion from data type ntext to data type varchar".

There is a lot of post available which describe how to avoid this problem, but all of them are related to the SQL layer not to the HQL nor Teneo mappings. It is said that this problem is caused by PreparedStatement automatically converting Strings longer than 4000 chars to the text type which doesn't correspond with the type in the DB.

My questions are:
Will this problem be fixed by removing @Lob from the annotation (will it stop the conversion to the text)
Is there any good tutorial in the area of Strings and Teneo (all I found was about JPA or something like that, but I am not really sure about the implementation of these concepts in Teneo)

Thank you for any suggestions!

Best

Lukas Zaruba
Re: [Teneo] String fields mapping (problem with ntext/varchar) [message #654111 is a reply to message #654109] Mon, 14 February 2011 09:21 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Lukas,
Yes I would try without the Lob annotation and see what happens then.The Lob annotation for sure will force a
clob/text/blob type.

gr. Martin

On 02/14/2011 10:09 AM, Lukas Zaruba wrote:
> Hi everyone,
> I ran into several difficulties with annotations of String fields. I tried to use JPA annotation to pass information to
> the persistent layer, and I managed to achieve some success, but now I am stucked with following problem.
>
> I have String field which can exceed 4000 chars. I tried to map this field with the following annotation: source =
> 'teneo.jpa', key = 'value', value = mailto:'@Lob
> @Column(length=65535)'
> As a result, in MSSQL 2008 and MySQL 5.1 it was mapped as text and longvarchar respectively.
>
> Which actually doesn't work for me, because it doesn't allow HQL Queries like select distinct a from A a left join ....
> because text field cannot be used in distinct and apparently previous query is translated into SQL in some way that the
> String field figures in the select.
>
> I tried changing the type of column in the DB (MSSQL 2000 - not possible to switch to the newer version yet) to
> varchar(8000) which would be sufficient, but now I am stucked with following error: "Caused by: java.sql.SQLException:
> Disallowed implicit conversion from data type ntext to data type varchar".
>
> There is a lot of post available which describe how to avoid this problem, but all of them are related to the SQL layer
> not to the HQL nor Teneo mappings. It is said that this problem is caused by PreparedStatement automatically converting
> Strings longer than 4000 chars to the text type which doesn't correspond with the type in the DB.
>
> My questions are:
> Will this problem be fixed by removing @Lob from the annotation (will it stop the conversion to the text)
> Is there any good tutorial in the area of Strings and Teneo (all I found was about JPA or something like that, but I am
> not really sure about the implementation of these concepts in Teneo)
>
> Thank you for any suggestions!
>
> Best
>
> Lukas Zaruba
>


--

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@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:EClass loading parameters dynamically from an XML file
Next Topic:Adding "GrandChild" feature to ItemProvider
Goto Forum:
  


Current Time: Sat Apr 27 04:00:18 GMT 2024

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

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

Back to the top