0
votes

Recently we changed from Nhibernate from 2.0 - Nhibernate 3.3. My state of system is as below.

A column in Sqlserver table is of "image" type . It is mapped to Nhibernate via hbm files. The listing is given below.

<property type="System.Byte[]" name="LayoutFile" length="2147483647">

  <meta attribute="read-only">false</meta>

  <meta attribute="nullable">true</meta>

  <meta attribute="value-type">false</meta>

  <column name="LayoutFile" sql-type="VARBINARY(max) length="2147483647"></column>

</property>

Though I have given the length and type specification. Still the error is thrown.

NHibernate.PropertyValueException: Error dehydrating property value for xxx.

NHibernate.HibernateException: The length of the string value exceeds the length configured in the mapping/parameter

I am not sure what is happening. I checked the size of data in DB which is only "260626"

1

1 Answers

0
votes

In case of binary data, I usually use type="BinaryBlob":

// instead of this
<property type="System.Byte[]" name="LayoutFile" length="2147483647">
 ...

// we should use this
<property type="BinaryBlob" name="LayoutFile" length="2147483647" />

Check also: How to map Image type in NHibernate?