I'm executing a stored procedure using GetNamedQuery and setting a string parameter using SetString. NHibernate sets the string parameter to be an NVarchar(4000). My string parameter value is actually longer than this and so gets truncated.
Is there any way to tell NHibernate to use a longer string type when executing the query? The query is defined in the mapping file as simply. exec dbo.ProcessUploads :courseId, :uploadxml
Edit: neither of my parameters are properties of the enties involved.
Since NHibernate doesn't have enough information to set the parameter length automatically, you have to do it manually.
Example:
session.GetNamedQuery("ProcessUploads")
       .SetParameter("courseId", courseId)
       .SetParameter("uploadXml", uploadXml, NHibernateUtil.StringClob)
       .ExecuteUpdate();
In this case I'm using StringClob, which would translate to NVARCHAR(max).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With