-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Problem with retrieving varchar field as String
PostPosted: Wed Apr 21, 2010 4:34 am 
Newbie

Joined: Wed Apr 21, 2010 4:26 am
Posts: 5
Hi,
I am using hibernate 3.2.6.ga and SYBASE ASE 5.5 server. I have declared a field IniConfig as VARCHAR(1000) in my table. The hibernate mapping for the same is as follows:
<property
name="iniConfig"
type="java.lang.String"
column="IniConfig"
length="1000"
/>

Now if I store a string with 300 characters in DB, hibernate fetches only the first 255 characters in POJO.
However if i enter a 300 character string in my GUI, hibernate saves it completely.
This works fine if I use TEXT type for IniConfig in in my SYBASE table instead of a VARCHAR(1000). But I want to know why hibernate does this and also want to know a workaround for this instead of using text because text field has performance issues.

Thanks,
Ayush


Top
 Profile  
 
 Post subject: Re: Problem with retrieving varchar field as String
PostPosted: Wed Apr 21, 2010 5:15 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
It could also be a problem of the jdbcdriver.
To detect this, I suggest you to log the result set (when fetching the data from database)
using p6spy.
Se we can see if it is the jdbc-driver truncing the String to 255 characters or if it is Hibernate which does if afterwards.


Top
 Profile  
 
 Post subject: Re: Problem with retrieving varchar field as String
PostPosted: Wed Apr 21, 2010 7:23 am 
Newbie

Joined: Wed Apr 21, 2010 4:26 am
Posts: 5
Hi using p6spy I can see the string bring truncated in the resultset itself.
So this does confirm that the JDBC driver needs to be upgraded right?
Right now I am using jconnect 2.5.5 (com.sybase.jdbc2.jdbc.SybDriver).

Thanks,
Ayush


Top
 Profile  
 
 Post subject: Re: Problem with retrieving varchar field as String
PostPosted: Wed Apr 21, 2010 7:52 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
Hi using p6spy I can see the string bring truncated in the resultset itself.
So this does confirm that the JDBC driver needs to be upgraded right?


Yes, at least it demonstrates, that hibernate is not the cause of the problem/
As first I would look for the most recent driver.
If the problem persists, I suggest to look at the specific jdbc documentation
if there are specific parameters which can be set in relation to this limitation.


Top
 Profile  
 
 Post subject: Re: Problem with retrieving varchar field as String
PostPosted: Thu Apr 22, 2010 4:49 am 
Newbie

Joined: Wed Apr 21, 2010 4:26 am
Posts: 5
Well, yes this was solved by setting the JCONNECT_VERSION property to value "6".
As our application maintains a jdbc.properties file for jdbc configuration all i had to do is modify this line:

DB_URL=jdbc:sybase:Tds:<serverName>:<port>?JCONNECT_VERSION=6

Thanks a lot for the help mate!

Regards,
Ayush


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.