How to get NHibernate to not truncate nvarchar(max) properties

237 views
Skip to first unread message

Michael Hedgpeth

unread,
Jun 20, 2011, 6:58:37 PM6/20/11
to nhusers
I recently upgraded from NHibernate 2.1 to 3.1. I am having a problem
with NHibernate truncating my nvarchar(max) columns. This post
describes my situation perfectly:
http://www.primordialcode.com/Blog/Post/nhibernate-prepare_sql-considerations-mapping-long-string-fields.

The current behavior seems to me to be a bug. If I give a simple
mapping:

<property name"LargeString" />

And the there is a column "LargeString" in the database with an
nvarchar(max) data type, it would be defective behavior to truncate
data retrieved by that column to 8000 characters. But that is exactly
what 3.1 does.

Could someone give me direction on how to handle this?

Fabio Maulo

unread,
Jun 21, 2011, 8:19:49 AM6/21/11
to nhu...@googlegroups.com
The simple mapping should be
<property name="LargeString" type="StringBlob"/>

Bas

unread,
Jun 21, 2011, 3:55:19 AM6/21/11
to nhusers
Hi Michael,

You can find the solution here:

http://www.basderaad.nl/2011/02/large-strings-in-nhibernate-3-0/

Bas

On Jun 21, 12:58 am, Michael Hedgpeth <mhedgp...@gmail.com> wrote:
> I recently upgraded from NHibernate 2.1 to 3.1.  I am having a problem
> with NHibernate truncating my nvarchar(max) columns.  This post
> describes my situation perfectly:http://www.primordialcode.com/Blog/Post/nhibernate-prepare_sql-consid....

Michael Hedgpeth

unread,
Jun 22, 2011, 10:24:49 AM6/22/11
to nhusers
Fabio was correct. In the latest GA of NHibernate, the mapping he
provided works.

I had gotten confused because my mapping was incorrect and I was
testing an update against a truncated insert. But when I tested a
round trip with NHibernate it worked like a charm.

Thanks, Fabio, for your help.
Reply all
Reply to author
Forward
0 new messages