6

I'm trying to make NHibernate generate my schema/SQL 2008, and using the mapping below it keeps wanting to create an nvarchar(255) column instead of text...any ideas?

    <property name="AnnouncementText" column="AnnouncementText" type="StringClob">
  <column name="AnnouncementText" sql-type="NTEXT"/>
</property>

Thanks!

2
  • 3
    wow 43 minutes from question posting to insertion in Google index...how does that happen???? Went searching for more hits and my own dang question came back.
    – Webjedi
    May 26, 2009 at 21:07
  • 1
    SO must have some sort of pact with the devil... I mean, Google ;-) May 27, 2009 at 16:43

3 Answers 3

9

The problem is specifying the name of the column twice...once I took it and the length out of the property element it worked perfectly

 <property name="AnnouncementText" type="StringClob">
  <column name="AnnouncementText" sql-type="text"/>
</property>
1
  • That's the problem, thanks I was looking around for a silly question like this one!
    – Raffaeu
    Nov 29, 2010 at 19:12
6

I'm used to SQL Server 2005 and the dialect it uses, but I presume you can do something similar. Since nvarchar(n) allows n up to 4000, a value above this will use nvarchar(max).

I presume that SQL Server 2000, which it sounds like you're using, does something similar once you hit the limit. If I read the NHibernate code correctly (NHibernate.Dialect.MsSql2000Dialect..ctor()) you get ntext once you pass 0xFA0 = 4000 characters.

<property name="AnnouncementText" column="AnnouncementText" type="string" length="10000"/>
2
  • 1
    Ooops forgot to mention I'm using SQL 2008 but with the 2005 dialect, but I'm actually trying to make a Text column, not an nvarchar(max).
    – Webjedi
    May 26, 2009 at 20:37
  • 1
    Btw, you should consider changing your text/ntext columns no varchar(max)/nvarchar(max) in 2005 and 2008 as the formers are being deprecated. Apr 20, 2010 at 10:54
-2

this won't help at all, but I remember the good old days ;-)...

create table YourTable
(
    ...
    AnnouncementText     text null
    ...

)
1
  • 1
    awh come on! I just find it so ironic that you have to struggle so hard to make a fancy auto-magical tool like NHibernate do something so simple!
    – KM.
    May 27, 2009 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.