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>
|