-->
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.  [ 6 posts ] 
Author Message
 Post subject: Truncated string property
PostPosted: Thu May 19, 2005 7:29 am 
Hi,

I have the following property definition:

Code:
<!-- column my_property, sql type varchar[16] -->
<property name="MyProperty" column="my_property" type="String(16)" />


A string which has more than 16 characters always get truncated to 16 in my current setup (NH 0.5, Sybase).

In the latest NH version, is it also the expected behaviour or should there be an exception here ?

cheers

Thibaut


Top
  
 
 Post subject:
PostPosted: Tue May 24, 2005 3:47 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
I don't remember seeing any truncating code in NHibernate, could it be Sybase truncating the string?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 26, 2005 1:20 am 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
I thought I answered this one already. Sorry...

The string(16) has nothing do do with the actual persistance of data in NH. Rather it is used in generating the tables from the mapping files. If your Sybase colum is indeed varchar(16) then Sybase is truncating the string when you persist the data. It works this waty in MSSQL2000 as well. (similar db engines). I'll bet mySQL does this too.

-devon


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 26, 2005 2:39 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 12:59 pm
Posts: 20
The syntax of type="String(16)" is an nh specific thing. What it does is generate IDbParameters with a length of 16. With MSSQL the IDbParameter will truncate the value at 16 chars. If it is specified as type="String" and a string that was 17 chars long was put in there then the database would throw an exception when the sql was executed.

The type="String(xx)" is something I never should have added, but I did it in an early version when I was having problems getting IDbCommand.Prepare() to work. I would have no complaints with ripping it out. I didn't know people were using it because I never really documented it (of course - you could say all of NH is not really documented :roll: )


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 26, 2005 6:15 pm 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
mike, thanks for correcting me.

my vote would be to remove that code, ut i am just one developer.

-devon


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 27, 2005 5:02 am 
oh. please do not remove it. Keep it undocumented.


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