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

Activity

Show:

Frédéric Delaporte December 14, 2017 at 11:57 AM

Moved here.

Resolved by fix.

Frédéric Delaporte August 4, 2017 at 5:54 PM
Edited

was fixed with this commit, probably doable likewise with ODBC and MsSqlCe. But ODBC may be used for other databases:

  • Does it makes sens to set parameter lengths for those other databases?

  • Could the SQL Server case fix cause trouble for them otherwise?

Obsolete

Details

Assignee

Reporter

Components

Fix versions

Priority

Who's Looking?

Open Who's Looking?

Created August 4, 2017 at 5:48 PM
Updated December 14, 2017 at 11:57 AM
Resolved December 14, 2017 at 11:56 AM
Who's Looking?