Blob binario truncado a 8000 bytes-SQL Server 2008 / varbinary (max)


He actualizado de Fluent Nhibernate 1.0 con Nhibernate 2.1 a pre- release 1.x con NHibernate 3.0 GA y han golpeado lo que creo que es una regresión, pero quiero escuchar si ese es el caso.

Estoy usando SQL Server Express 2008 y el dialecto MSSQL 2008 y tengo un Imagen propiedad del tipo System.Dibujo.Imagen y lo he mapeado como esto:

Map (food => food.Image)
 .Length (int.MaxValue)
 .Nullable ();

La columna Image del cuadro es de tipo varbinary(MAX).

El hbm generado para la propiedad is:

<property name="Image" type="System.Drawing.Image, System.Drawing,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
   <column name="Image" length="2147483647" not-null="false" />
</property>`

Sin embargo, no importa lo que haga el blob binario se trunca a 8000 bytes cuando se serializa con las versiones FNH y NH actuales. Que no usó para ser el caso con versiones anteriores.

Ideas de por qué está sucediendo esto y cómo solucionarlo/solucionarlo?

Author: marc_s, 2011-01-03

5 answers

Yo también me he encontrado con un problema similar y después de mucha experimentación me di cuenta de que cuando se utiliza Nhibernate para generar mi esquema a un archivo el tipo de columna generada era siempre longitud 8000.

Configurar CustomSqlType a Varbinary (max) como se sugirió anteriormente no hizo ninguna diferencia, sin embargo, este trabajo en mi FluentMapping parecía hacer el truco:

Map(x => x.LogoBytes).CustomType("BinaryBlob").Length(1048576).Nullable();  

La duración, por supuesto, es una cantidad arbitraria, pero creo que debería establecerse en algo menor que int.Max. Soy nuevo para Nhibernate así que todavía estoy averiguando las cosas pero me interesaría saber si esto te ayuda.

 22
Author: sbeskur,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-02-04 20:47:34

En 3.0.0 GA, el siguiente mapeo parece hacer el truco:

        <property name="Data" type="Serializable" length="2147483647" />
 5
Author: Michael Teper,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-01-31 07:26:02

Esto es una regresión. He planteado un error y proporcionado parches en https://nhibernate.jira.com/browse/NH-2484

 4
Author: Ivan Zlatev,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-05-01 11:13:15

Mapa (x = > x. Imagen).Longitud(100000).Ni.Nullable ();

Añade el 'Length (MAXVALUE)' como arriba y funcionará:)

 1
Author: Kev,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-08-19 11:47:56

¿has probado esto?

Map(x => x.Image).CustomSqlType("VARBINARY(MAX)");
 0
Author: Rippo,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-01-03 13:16:41