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: strings longer then 255 are trancated
PostPosted: Thu Mar 02, 2006 11:35 am 
Newbie

Joined: Thu Mar 02, 2006 11:12 am
Posts: 3
Hello,
I've been using hibernate to persist and query objects which contain large strings. It has recently come to my attention that when I query these objects, hibernate trancates these long strings if they are bigger then 255 chars. This problem occurs only when hibernate retrieves these values from the database, but it does persist them just fine. I tried setting the length attribute and change the type to text of the columns in question, but this did not fix the problem. Please forgive my stupidity if I am not doing the right thing. If somebody knows how to fix this, I thank you in advance.

Hibernate version:3.1

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="com.hsbc.MFMessages.TBATradePriceState" table="TBATradePriceStates">
<cache usage="read-write"/>

<composite-id>
<key-property name="tradeNumber"/>
<key-property name="tradeDate" type="date"/>
</composite-id>

<property name="sourceType"/>
<property name="isFrontMonth"/>
<property name="hostName"/>
<property name="sourceName"/>
<property name="askDesc" type="string" length="1000"/>
<property name="bidDesc" type="string" length="1000"/>
<property name="qType"/>
<property name="timeStamp"/>
<property name="expireTime"/>
<property name="bid"/>
<property name="ask"/>
<property name="mid"/>
<property name="change"/>
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Criteria criteria = buildCriteriaFromTBAMessage(session, myCriteriaMessage);
criteria.setCacheable(true);
criteria.setCacheRegion("Quotes");
List result = criteria.list();
return result;

Name and version of the database you are using:
Sybase ASE 12.5

Debug level Hibernate log excerpt:
DEBUG [Thread-3] type.StringType 03/02 10:06:49 - returning '<FwdRoll><FwdRoll><AgySwap><Q><D>GARBAN</D><D> FN 5.5 MR</D><D> Ask </D><D> 98.578125</D><D> 3/2/2006 9:08:40:366 AM</D></Q><Q><D>GARBAN</D><D> GD-FN 5.5 MR</D><D> Ask </D><D> 0.0703125</D><D> 3/2/2006 8:39:05:007 AM</D></Q></AgySwap><Q><D>PATRIOT</D><D> ' as column: askDesc1_0_
DEBUG [Thread-3] type.StringType 03/02 10:06:49 - returning '<FwdRoll><FwdRoll><AgySwap><Q><D>GARBAN</D><D> FN 5.5 MR</D><D> Bid </D><D> 98.5625</D><D> 3/2/2006 9:08:40:366 AM</D></Q><Q><D>GARBAN</D><D> GD-FN 5.5 MR</D><D> Bid </D><D> 0.06640625</D><D> 3/2/2006 8:39:05:007 AM</D></Q></AgySwap><Q><D>PATRIOT</D><D> G' as column: bidDesc1_0_

Actual values from the database:
askDesc: <FwdRoll><FwdRoll><AgySwap><Q><D>GARBAN</D><D> FN 5.5 MR</D><D> Ask </D><D> 98.578125</D><D> 3/2/2006 9:08:40:366 AM</D></Q><Q><D>GARBAN</D><D> GD-FN 5.5 MR</D><D> Ask </D><D> 0.0703125</D><D> 3/2/2006 8:39:05:007 AM</D></Q></AgySwap><Q><D>PATRIOT</D><D> GD 5.5 MR/AP</D><D> Bid </D><D> 0.08203125</D><D> 3/2/2006 8:31:28:376 AM</D></Q></FwdRoll><Q><D>CLOSES</D><D> GD 5.5 AP/MA</D><D> Bid </D><D> 0.0859375</D><D> 3/2/2006 5:00:00:196 AM</D></Q></FwdRoll>

bidDesc: <FwdRoll><FwdRoll><AgySwap><Q><D>GARBAN</D><D> FN 5.5 MR</D><D> Bid </D><D> 98.5625</D><D> 3/2/2006 9:08:40:366 AM</D></Q><Q><D>GARBAN</D><D> GD-FN 5.5 MR</D><D> Bid </D><D> 0.06640625</D><D> 3/2/2006 8:39:05:007 AM</D></Q></AgySwap><Q><D>PATRIOT</D><D> GD 5.5 MR/AP</D><D> Ask </D><D> 0.0859375</D><D> 3/2/2006 8:31:28:376 AM</D></Q></FwdRoll><Q><D>CLOSES</D><D> GD 5.5 AP/MA</D><D> Ask </D><D> 0.09375</D><D> 3/2/2006 5:00:00:196 AM</D></Q></FwdRoll>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 5:23 pm 
Newbie

Joined: Thu Mar 02, 2006 11:12 am
Posts: 3
so, is this a bug or am I missing something?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 10:53 am 
Regular
Regular

Joined: Tue Jan 03, 2006 9:52 am
Posts: 52
Location: Zurich
I think, this is probably a jdbc driver issue and not related to hibernate.

Look at the following link:
http://groups.google.ca/group/microsoft.public.sqlserver.programming/msg/e1fd93c145f094fe?q=jdbc+varchar+string+truncate&hl=en&lr=&ie=UTF-8&oe=UTF-8&rnum=7

Urs


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 6:26 am 
Regular
Regular

Joined: Tue Jan 03, 2006 9:52 am
Posts: 52
Location: Zurich
Hello,
I could verify your problem. The string length is always 255 wheather you use JDBC queries or if you use hibernate.
So it is definitely a JDBC driver issue.

When you switch to jconnect-6.0 and use the driver (replace jar file), it works with hibernate as well.

Extract of hibernate.cfg.xml
<property name="hibernate.connection.driver_class">com.sybase.jdbc3.jdbc.SybDriver</property>

Hope this helps!
Urs


Top
 Profile  
 
 Post subject: thank you
PostPosted: Sun Mar 12, 2006 2:01 pm 
Newbie

Joined: Thu Mar 02, 2006 11:12 am
Posts: 3
thanks this works


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.