I am trying to call a stored procedure in my database. But rather than using indexes for my parameters I want to use the param name that the stored procedure in the db has. This however doies not work and throws an error saying that "Not all named parameters have been set: []"
Hibernate version:
NHibernate 1.2.0 Beta 2
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Server.Test, Server" table="Table01" lazy="false">
<id name="Key" column="myKey" unsaved-value="null">
<generator class="assigned" />
</id>
<property name="MyValue" column="myName" type="String" length="50"/>
<sql-insert check="none"> exec up_InsertData ?, ?</sql-insert>
<sql-update>exec up_UpdateData ?, ?</sql-update>
<sql-delete check="none" >exec up_DeleteData ?</sql-delete>
</class>
<sql-query name="GetAllData">
<return alias="up_GetData" class="Server.Test, Server" >
<return-property name="Key" column="myKey"/>
<return-property name="MyValue" column="myName"/>
</return>
exec up_GetData
</sql-query>
<sql-query name="GetSomeData">
<return alias="up_GetData" class="Server.Test, Server" >
<return-property name="Key" column="myKey"/>
<return-property name="MyValue" column="myName"/>
</return>
exec up_GetSomeData minKey
</sql-query>
<sql-query name="UpdateSomeData">
<return alias="up_UpdateData" class="Server.Test, Server" />
exec up_UpdateData ?, ?
</sql-query>
<sql-query name="InsertSomeData">
<return alias="up_InsertData" class="Server.Test, Server" />
exec up_InsertData ?, ?
</sql-query>
<sql-query name="DeleteSomeData">
<return alias="up_DeleteData" class="Server.Test, Server" />
exec up_DeleteData ?
</sql-query>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
IList testList = session.GetNamedQuery("GetSomeData")
.SetParameter("minKey", key)
.List();
Full stack trace of any exception that occurs:
An unhandled exception of type 'NHibernate.QueryException' occurred in NHibernate.dll
Additional information: Not all named parameters have been set: []
I would like to use named params instead of indexes so that if the order of the params changes in the stored procedure the code will not need to be changed and recompiled. How do i do this?
Clare Stinton
|