Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6351987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:07:00+00:00 2026-05-24T22:07:00+00:00

I am calling a stored procedure as a NamedQuery and it’s working fine. The

  • 0

I am calling a stored procedure as a NamedQuery and it’s working
fine.
The problems start when I try to load a component.
The stored procedure returns a recordset like this

[ IDEmployee, EmployeeName, City, Country ]

Where IDEmployee and EmployeeName belong to the mapped entity and City and Country are from a component

Here comes the mapping:

<class name="Employee" table="employees"> 
    <id name="IDEmployee"> 
      <column name="idemployee" /> 
      <generator class="native" /> 
    </id> 
    <property name="EmployeeName "> 
      <column name="employeename" /> 
    </property> 
    <component name="Address" class="Address"> 
      <property name="City"> 
        <column name="city" /> 
      </property> 
      <property name="Country"> 
        <column name="country" /> 
      </property> 
    </component> 
  </class> 

This is the code I use for calling the stored procedure:

  <sql-query name="GetEmployeesByCompany"> 
    <return class="Employee"> 
      <return-property column="idemployee" name="IDEmployee" /> 
      <return-property column="employeename" name="EmployeeName" /> 
      <return-property column="city" name="City" /> 
      <return-property column="country" name="Country" /> 
    </return> 
    EXEC GetEmployeeByCompany:idcompany 
  </sql-query> 

Here the code I use to call the stored:

 var result = 
    session<ISession>().GetNamedQuery("GetEmployeesByCompany") 
                .SetInt32("idcompany", companyId) 
                .List<Employee>().ToList(); 

Here the error I get when I run my app

System.IndexOutOfRangeException: t1_282_0_ 
   at System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) 
   at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name) 
in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Type\NullableType.cs:line 236 
   at NHibernate.Persister.Entity.AbstractEntityPersister.Hydrate(IDataReader rs, Object id, Object obj, ILoadable rootLoadable, String[][] suffixedPropertyColumns, Boolean allProperties, ISessionImplementor session)
in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs:line 2508
   at NHibernate.Loader.Loader.LoadFromResultSet(IDataReader rs, Int32 i, Object obj, String instanceClass, EntityKey key, String rowIdAlias, LockMode lockMode, ILoadable rootPersister, ISessionImplementor session) 
in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Loader\Loader.cs:line 991 

If i remove from the map the component everything works fine.
I also tried something with return-property with nested return-column with no success.

Any tip? Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:07:01+00:00Added an answer on May 24, 2026 at 10:07 pm

    I had to face this problem lately, this is the way I could come out.

    <sql-query name="GetEmployeesByCompany">
      <return class="Employee">
        <return-property column="idemployee" name="IDEmployee" />
        <return-property column="employeename" name="EmployeeName" /> 
        <return-property name="Address">  <!-- name of the component -->
          <return-column name="city" />  <!-- name of the resultset field -->
          <return-column name="country" />  <!-- name of the resultset field -->
        </return-property>
    </return> 
    EXEC GetEmployeeByCompany:idcompany 
    

    The order you use for the fields inside the return property is very important it must match the one in the resultset. There is no documentation at all around, I hope this can help you!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm calling a stored Procedure in classic asp I'm adding my parameter like that
I'm calling a stored procedure on a SQL Server 2005 database which returns an
I am manually calling a stored procedure using an Entity Framework EntityConnection like so:
I am currently having problems calling a stored procedure async from within a insert-update-trigger.
I am using NHibernate and calling a stored procedure via a named query: <sql-query
We have a winforms application calling a stored procedure every few seconds. The stored
I'm getting the following error when calling a stored procedure: Cannot find the object
How can I ignore an output parameter of a stored procedure? I'm calling the
I really want to know your experience at working with ADO.Net datasets (calling stored
HI I am getting this exception when I am calling any stored procedure from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.