MsSql Dialect + ODBC, mapping an nvarchar(max) using string(10000) causes string truncation

Description

The fixed has forgot about Odbc and MsSqlCe, which had also been impacted by the seemingly rogue change "set param len" for optimizing query plan cache usage. (Commit 03eb58acae867e2d5620446c3b07cb91e7d74422.) Below is the description.

In NHibernate 2.1 we were used to map nvarchar(max) columns using something like this:

<property name="propertyname" column="columnname" type="string" length="10000" />

When using SchemaExport() this mapping correctly generates a nvarchar(max) column, but when reading and writing to the column the text is truncated to the size limit of the length specified in the mapping (10k chars in this care): if I try to store a string whose length is 12k chars I get back a 10k chars string.

Using a StringClob mapping and specifying the correct sql-type (like in the following snippet) seems to resolve the problem:

<property name="BlobSqlType" type="StringClob" >
<column name="BlobSqlType" sql-type="nvarchar(max)" />
</property>

Any other combination I've tried doesn't seem to work. This will introduce an unwanted dependency in the mappings and will force us to review all the mappings in our project if we want to switch over to NHibernate 3

Environment

None

Status

Assignee

Frédéric Delaporte

Reporter

Alessandro Giorgetti

Labels

None

Components

Fix versions

Priority

Major
Configure