-->
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.  [ 3 posts ] 
Author Message
 Post subject: SchemaExport converts StringClob to NVARCHAR(255)
PostPosted: Wed Jan 25, 2006 4:25 pm 
Newbie

Joined: Wed Jan 25, 2006 3:45 pm
Posts: 2
We are seeing a small issue with the MSSQL2000 dialect. I will try to explain the best I can.

We have a class with a mapping file like this:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Example.Demo, Example" table="Example" mutable="true">
<id name="Id" type="Int32" unsaved-value="0">
<column name="id" not-null="true" unique="true" index="PK_Example"/>
<generator class="native" />
</id>
<property name="Created" type="DateTime">
<column name="created" not-null="false"/>
</property>
<property name="Updated" type="DateTime">
<column name="updated" not-null="false"/>
</property>
<property name="Title" type="AnsiString">
<column name="title" length="100" not-null="false"/>
</property>
<property name="Description" type="AnsiString">
<column name="description" length="255" not-null="false"/>
</property>
<property name="Content" type="StringClob" >
<column name="content" length="2147483647" not-null="false"/>
</property>
</class>
</hibernate-mapping>



When we use SchemaExport.Create(), the "Content" / StringClob column gets generated as a nvarchar(255). This appears to be a default representation of the column. I added the following line to the MSSQL2000 dialect to attempt to resolve the problem for us but I am not sure if this is the best approach (i.e. is there a way to improve my mapping file):
RegisterColumnType( DbType.String, 2147483647, "TEXT" ); // HACK TO TEMP. FIX TEXT DEFAULTING TO NVARCHAR(255)

Any help is appreciated.


Top
 Profile  
 
 Post subject: StringClob to NText works fine for me
PostPosted: Thu Feb 02, 2006 7:21 am 
Newbie

Joined: Mon Jun 27, 2005 5:12 am
Posts: 10
Hi

I'm using NHibernate 1.0.2.0 and have StringClob mappings for my NText fields. Using MsSql2000Dialect I've done a SchemaExport.Create(true, true) and the fields were created with the correct, NText, type.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 02, 2006 11:47 am 
Newbie

Joined: Wed Jan 25, 2006 3:45 pm
Posts: 2
I should expand on my previous post that we are using a "text" typed column in SqlServer 2000 and not an "ntext" column. In my experience, that has worked as expected.

I think the right solution is to use an AnsiString mapping with a width of "2147483647". This will generate a text column properly. This just seems a bit counterintuitive to not use the StringClob.


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