-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate is returning a truncated value from SQL Server2000
PostPosted: Tue May 03, 2005 6:28 pm 
Newbie

Joined: Tue May 03, 2005 6:14 pm
Posts: 1
Hello

I am new to hibernate but have played with it enough to implement it within a product. I am working a support issue currently where a customer is seeing within a dialogue box (swing JTextField) that the value of APM_SCENARIOS_NAMED_VALUES_TAB.val is truncated to 255 characters.

The DB is correct and is set to VARCHAR(2000). I even recreated all the tables to make sure that wasnt it.

Now the funny thing is the dev DB instance of our customer is not having this while the prod instance is. I have not been able to reproduce this until just recently.

This is the value in the DB (its long and ugly, with some URLencoded characters)

/login/00login.fcc?TYPE=33554433&REALMOID=06-781e84be-e97b-40f0-896c-8ba85b7f7d69&GUID=&SMAUTHREASON=0&METHOD=GET&SMAGENTNAME=-SM-rTgCiRj%2fV8CXRrxJRRWPvpKrFMSIBqse%2brBHGHgkpSqmIs6aLrOE7g%3d%3d&TARGET=-SM-http%3a%2f%2fnlaasp05server1%2esubsidia%2eorg%3a8001%2fcarteclient%2fdefault%2easp

But it alwayws comes out as

/login/00login.fcc?TYPE=33554433&REALMOID=06-781e84be-e97b-40f0-896c-8ba85b7f7d69&GUID=&SMAUTHREASON=0&METHOD=GET&SMAGENTNAME=-SM-rTgCiRj%2fV8CXRrxJRRWPvpKrFMSIBqse%2brBHGHgkpSqmIs6aLrOE7g%3d%3d&TARGET=-SM-http%3a%2f%2fnlaasp05server1%2esubsidia%2eorg%3a8

its basically cut-off at 255 characters. Now if I use some code we have that imports data via an XML stream. It goes into the database fine. Once I update, then it overwrites the DB.

I thought it might have to do with collation but that was confirmed not an issue.

Any help would be great.

One more note. I do get a reflection error, I thought it may have to do with the column="val" type="string" length="2000" for an element node under the map collection.

2005-04-26 11:24:46,238 INFO net.sf.hibernate.util.ReflectHelper - reflection optimizer disabled for: com.mosol.integration.apm.data.bean.Scenario, InstantiationError: com.mosol.integration.apm.data.bean.Scenario





Hibernate version: version 2.1.2

Mapping documents:

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

<hibernate-mapping default-cascade="all">
<class name="com.mosol.integration.apm.data.bean.Scenario" table="APM_SCENARIOS_TAB" discriminator-value="null">
<cache usage="read-write"/>
<id name="id" type="long" unsaved-value="0">
<generator class="increment"/>
</id>
<discriminator column="scenario_type" type="string" not-null="false" force="true" />
<property name="name" column="name" type="string" length="2000"/>
<property name="type" column="scenario_type" insert="false" update="false"/>
<property name="shared" column="is_shared"/>
<property name="timeCreated" type="timestamp"/>
<property name="lastUpdated" type="timestamp"/>
<map name="namedValues" table="APM_SCENARIOS_NAMEDVALUES_TAB" cascade="all">
<cache usage="read-write"/>
<key column="scenario_id" />
<index column="name" type="string" length="150"/>
<element column="val" type="string" length="2000" />
</map>
<set name="responseTimeThresholds" cascade="all" table="APM_SCENARIOS_RT_THRESH_TAB">
<cache usage="read-write"/>
<key>
<column name="scenario_id" not-null="true" />
</key>
<composite-element class="com.mosol.integration.apm.data.bean.Scenario$Threshold">
<property name="alarmSeverity"/>
<property name="alarmDescription"/>
<property name="type" column="rt_type"/>
<property name="lower" column="lo" />
<property name="upper" column="hi" />
</composite-element>
</set>
</class>

<class name="com.mosol.integration.apm.data.bean.ScenarioActivation" table="APM_TESTS_SCENARIOS_TAB" >
<composite-id unsaved-value="any">
<key-many-to-one name="test" column="test_id" class="com.mosol.integration.apm.data.bean.Test" />
<key-many-to-one name="scenario" column="scenario_id" class="com.mosol.integration.apm.data.bean.Scenario" />
<key-property name="position" column="pos"/>
</composite-id>
<property name="active" column="is_active"/>
<many-to-one name="identity" column="identity_id" class="com.mosol.integration.apm.data.bean.Identity" />
<many-to-one name="proxy" column="proxy_id" class="com.mosol.integration.apm.data.bean.Proxy" />
<many-to-one name="cookie" column="cookie_id" class="com.mosol.integration.apm.data.bean.Cookie" />
</class>

<query name="scenarioOrphans"><![CDATA[

from com.mosol.integration.apm.data.bean.Scenario as scenario
where not exists(
from com.mosol.integration.apm.data.bean.ScenarioActivation as activation
where activation.scenario = scenario
and scenario.shared = false )

]]></query>

<query name="scenarioActivations"><![CDATA[

from com.mosol.integration.apm.data.bean.ScenarioActivation as activation
where activation.scenario = ?

]]></query>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():


Full stack trace of any exception that occurs:

Name and version of the database you are using:

SQL Server 2000 with SP2

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: it could be your driver
PostPosted: Wed Jun 29, 2005 3:20 pm 
Newbie

Joined: Tue Sep 09, 2003 3:39 am
Posts: 14
Location: Atlanta, GA
I ran into the same problem and searched the forums here first before I found out that it was actually an issue with the driver that I was using.

I guessed the driver might be at fault, since it was some bizarre relic that had been hanging around in the system for years (and since there were not many posts or google results for 'hibernate truncate 255'), so I took hibernate out of the equation by writing some simple jdbc code that exhibited the same problem.

Anyway, the com.inet.tds.TdsDriver MS SQLServer driver requires an optional param: "sql7=true" to not truncate varchar data at 255 chars.

The opensrc jtds driver works just fine, BTW.

Moral of the story: trust hibernate before you trust your jdbc driver. :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.