I am using Nhibernate 2.1.0 in my project.
I have the an Item class with property Path and the following named
query:
<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2'>
<sql-query name='updateUNC'>
<query-param name='oldUNC' type='String'/>
<query-param name='newUNC' type='String'/>
<![CDATA[
update Item s set
s.Path= replace(s.Path,:oldUNC, :newUNC),
]]>
</sql-query>
</hibernate-mapping>
I execute the named query using the following code:
session.GetNamedQuery("updateUNC")
.SetString("oldUNC", "old")
.SetString("newUNC", "new")
.ExecuteUpdate();
But I get the following exception:
NHibernate.Hql.Ast.ANTLR.QuerySyntaxException was unhandled
Message="Can't determine SqlType of parameter name=oldUNC,
expectedType=Unknow\n Possible cause: wrong case-sensitive
property-name."
Source="NHibernate"
StackTrace:
at NHibernate.Hql.Ast.ANTLR.Exec.BasicExecutor.Execute
(QueryParameters parameters, ISessionImplementor session) in C:
\Projects\Nhibernate\nhibernate2.1.0\src\NHibernate\Hql\Ast\ANTLR\Exec
\BasicExecutor.cs:line 66
at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.ExecuteUpdate
(QueryParameters queryParameters, ISessionImplementor session) in C:
\Projects\Nhibernate\nhibernate2.1.0\src\NHibernate\Hql\Ast\ANTLR
\QueryTranslatorImpl.cs:line 149
at NHibernate.Engine.Query.HQLQueryPlan.PerformExecuteUpdate
(QueryParameters queryParameters, ISessionImplementor session) in C:
\Projects\Nhibernate\nhibernate2.1.0\src\NHibernate\Engine\Query
\HQLQueryPlan.cs:line 328
at NHibernate.Impl.StatelessSessionImpl.ExecuteUpdate(String
query, QueryParameters queryParameters) in C:\Projects\Nhibernate
\nhibernate2.1.0\src\NHibernate\Impl\StatelessSessionImpl.cs:line 962
at NHibernate.Impl.QueryImpl.ExecuteUpdate() in C:\Projects
\Nhibernate\nhibernate2.1.0\src\NHibernate\Impl\QueryImpl.cs:line 120
at Catalog.Repository.ItemsRepository.ChangeUNC(String oldUNC,
String newUNC) in C:\Projects\Catalog\Catalog\Repository
\ItemsRepository.cs:line 148
I also tried setting the parameter value using SetParameter<string>
and SetParameter(":oldUNC", "old" NHibernateUtil.String) but it also
failed with the same error. It is like NHibernate just ignore me
saying that the parameter value is string :(.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---