Reputation: 350
I think I'm going crazy on this one : it's a fairly simple scenario and should be documented, but... no!
Here is my stored procedure declaration:
CREATE PROCEDURE [dbo].[spImport]
(
@xmlDocument AS XML
)
AS
---
GO
Here is my mapping:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="XXX"
namespace="XXX.Entities">
<sql-query name="spImport">
<![CDATA[EXEC [dbo].[spImport] @xmlDocument = :xmlDocument]]>
</sql-query>
</hibernate-mapping>
And Here is the calling method:
session.GetNamedQuery("spImport").SetParameter("xmlDocument", document, NHibernateUtil.XmlDoc).ExecuteUpdate();
Now, I'm getting the follinging error:
While preparing EXEC [dbo].[spImport] @xmlDocument = @p0 an error occurred InnerException: SqlCommand.Prepare method requires all variable length parameters to have an explicitly set non-zero Size.
Thanks for your help, Stefan
Upvotes: 2
Views: 846
Reputation: 15413
Never took time to really solve the XmlType length problem . Would be interested in the "clean" answer. Anyway, here is my workaround :
I assume you are using a NHibernateUtil.XmlDoc: IUserType.
As SqlTypes implementation, I have :
public SqlType[] SqlTypes
{
get
{
return new SqlType[] { new SqlXmlType() };
}
}
where SqlXmlType is :
public class SqlXmlType : SqlType
{
public SqlXmlType() : base(System.Data.DbType.Xml,5000000)
{
}
}
Allowing me to handle up to 5 Mo XmlDocs
Hope this will help
Upvotes: 1