升级到3.3.1后NHibernate Mapping错误。错误使xxx的属性值脱水

时间:2015-10-22 10:00:20

标签: nhibernate nhibernate-mapping

最近我们从Nhibernate改为2.0 - Nhibernate 3.3。我的系统状态如下。

Sqlserver表中的列是“image”类型。它通过hbm文件映射到Nhibernate。列表如下。

<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>

虽然我已经给出了长度和类型规格。仍然会抛出错误。

  

NHibernate.PropertyValueException:使xxx的属性值脱水错误。

     

NHibernate.HibernateException:字符串值的长度超过映射/参数中配置的长度

我不确定发生了什么。我检查了DB中仅为“260626”

的数据大小

1 个答案:

答案 0 :(得分:0)

如果是二进制数据,我通常使用type="BinaryBlob"

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

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

同时检查:How to map Image type in NHibernate?

相关问题