NHibernate Stored procedure with XML parameter

149 views
Skip to first unread message

Stefan EHRET

unread,
Dec 11, 2012, 4:39:19 AM12/11/12
to nhu...@googlegroups.com
Hi everyone!  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

PS: I DO have a workaround! I'm looking for a clean solution

Carlos Souto

unread,
Sep 16, 2014, 9:40:27 AM9/16/14
to nhu...@googlegroups.com
Hi Stefan.

I am struggling with the same issue.

Could you please post your workaround? I am trying to use it but still no luck.

Cheers

Carlos

Ricardo Peres

unread,
Sep 16, 2014, 5:58:27 PM9/16/14
to nhu...@googlegroups.com
Why don't you create an issue at nhibernate.jira.com, with a simple test?
I can confirm that the problem happens. As a workaround, you can try disabling the preparation of commands:

cfg.SetProperty(NHibernate.Cfg.Environment.PrepareSql, Boolean.FalseString);

RP
Reply all
Reply to author
Forward
0 new messages