I am having trouble mapping our byte[]
field. I've been looking for several solutions but none work so far. All I get is this exception:
The length of the byte[] value exceeds the length configured in the mapping/parameter.
Below is what I've got so far in the hbm.xml
<property name="Data" type="BinaryBlob">
<column name="attachmentData" sql-type="varbinary(max)"/>
</property>
Am I doing something not right here?
Update - Solution:
It turned out that I have done it incorrectly. We are inserting the byte[]
via stored procedure so the property mapping has nothing to do with it. Instead, we need to tell NHibernate the type of the sprocs parameter like so:
query.SetParameter(param.Key, param.Value, NHibernateUtil.BinaryBlob);
NHibernate doesn't understand varbinary(max) and will use the default of 8000 bytes.
Therefore you will need to supply the number. I.e.
varbinary(2147483647)
I think used to work but is a regression bug.