[Teneo] String fields mapping (problem with ntext/varchar) [message #654109] |
Mon, 14 February 2011 09:08 |
Lukas Zaruba 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 |
Martin Taal 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
|
|
|
Powered by
FUDForum. Page generated in 0.03338 seconds