HBM image display / binary

I'm having trouble displaying our byte[] field. I have been looking for several solutions, but not working yet. All I get is an exception:

 The length of the byte[] value exceeds the length configured in the mapping/parameter. 

Below is what I still have in hbm.xml

 <property name="Data" type="BinaryBlob"> <column name="attachmentData" sql-type="varbinary(max)"/> </property> 

Am I doing something wrong?

Update - Solution:

It turned out that I did it wrong. We insert byte[] through the stored procedure , so the mapping of properties has nothing to do with this. Instead, we need to specify the NHibernate sprocs parameter type as follows:

 query.SetParameter(param.Key, param.Value, NHibernateUtil.BinaryBlob); 
+4
source share
1 answer

NHibernate does not understand varbinary (max) and will use 8000 bytes by default.

Therefore, you will need to specify a number. I.e.

VARBINARY (2147483647)

I think I'm used to working, but is a regression .

+4
source

All Articles