Hi
I'm encountering a strange problem when I try to execute a stored procedure in my database.
I'm working against Microsofts NorthWind example database and the stored procedure I'm trying to run is the one named "Ten Most Expensive Products". To be able to handle the result from the sp I have created a view on the database side containing two columns (one for the name of the product and one for the price), I've includede the mapping for the view and my stored procedure below. When I run the code I get the exeception:
"Could not execute query
[ exec [Ten Most Expensive Products] ]
[SQL: exec [Ten Most Expensive Products]]"
And examining the InnerExeception makes me no wiser since it tells me: "TenMostE1_14_0_"
The sp itself runs fine when I run it directly on SQL Server.
Any ideas what I'm doing wrong?
NHibernate version: 1.2.0
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="NorthWindNHibernate.ProductAndPriceEntity, NorthWindNHibernate" table="ProductAndPrice">
<composite-id>
<key-property name="tenMostExpensiveProducts" column="TenMostExpensiveProducts" type="System.String" length="40"></key-property>
<key-property name="unitPrice" column="UnitPrice" type="System.Decimal"></key-property>
</composite-id>
</class>
<sql-query name="Ten_Most_Expensive_Products">
<return alias="tenProducts" class="NorthWindNHibernate.ProductAndPriceEntity, NorthWindNHibernate">
<return-property name="tenMostExpensiveProducts" column="TenMostExpensiveProducts"/>
<return-property name="unitPrice" column="UnitPrice"/>
</return>
exec [Ten Most Expensive Products]
</sql-query>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Code:
try
{
IList products = session.GetNamedQuery("Ten_Most_Expensive_Products").List();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Full stack trace of any exception that occurs:
A first chance exception of type 'System.IndexOutOfRangeException' occurred in System.Data.dll
A first chance exception of type 'NHibernate.ADOException' occurred in NHibernate.dll
Name and version of the database you are using:
MS SQL Server 2005