Is the order of params important in NHibernate?

Posted by Blake Blackwell on Stack Overflow See other posts from Stack Overflow or by Blake Blackwell
Published on 2010-04-13T16:06:35Z Indexed on 2010/04/13 16:13 UTC
Read the original article Hit count: 317

Filed under:
|
|

If I have an int parameter followed by a string parameter in a sproc I get the following error:

Input string was not in the correct format

However, if I switch those parameters in the sproc than I get the result set I expect. Are params sorted by data type, or do I have to do anything special in my config file? I've included my code for reference:

Config File

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                   assembly="NHibernateDemo"
                   namespace="NHibernateDemo.Domain">  
  <class name="Blake_Test" table="Blake_Test">
    <id name="TestId" column="TESTID"></id>
    <property name="TestName" column="TESTNAME" />
    <loader query-ref="GetBlakeTest"/>
  </class>
  <sql-query name="GetBlakeTest" callable="true">      
      <return class="Blake_Test" />
      call procedure AREA51.NHIBERNATE_TEST.GetBlakeTest(:int_TestId, :vch_TestName)
  </sql-query> 
</hibernate-mapping>

Sproc Code:

  PROCEDURE GetBlakeTest
  (
      ret_cursor OUT SYS_REFCURSOR,
      int_testid integer,
      vch_testname varchar2                
  ) AS
  BEGIN

   OPEN ret_cursor FOR
   SELECT TestId, TestName FROM blake_test WHERE testid = int_testid ORDER BY TestName DESC;

  END GetBlakeTest;
END NHIBERNATE_TEST;

Executing Code:

IQuery query1 = session.GetNamedQuery( "GetBlakeTest" );
query1.SetParameter( "int_TestId", 1 ); 
query1.SetParameter( "vch_TestName", "TEST" );                                      
IList<Blake_Test> mystuff = query1.List<Blake_Test>();

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about odp.net