0

my package contains the following procedure -->

Package body myNewack as Procedure DisplayEmployees(Emplist OUT refCursor) Is begin open Emplist for select EmpId, FirstName, LastName from employee; end; end myNewPack;

my hbm mapping file contains the following named query -->

<sql-query name="mytestsp" callable="true">
 call MYNEWPACK.DISPLAYEMPLOYEES()
</sql-query>

and from .net i'm using the following code to call this procedure

public IList<NhbHelper.Employee> GetEmployees()
{
  IList<NhbHelper.Employee> myList;
  ISession session = NHibernateHelper.GetCurrentSession();
  var query= session.GetNamedQuery("mytestsp");
  return query.List<NhbHelper.Employee>();
}

Whenever i'm executing this code i'm getting error "Could not execute query [ call MYNEWPACK.DISPLAYEMPLOYEES()] [SQL:call MYNEWPACK.DISPLAYEMPLOYEES()]"

Kindly help me fix this issue, how can i execute the oracle procedure that returns refcursor

1 Answer 1

0

I guess you're missing the return definition in your hbm mapping file.
It should be something like that:

<sql-query name="mytestsp" callable="true">
    <return class="NhbHelper.Employee, NhbHelper" />
    call MYNEWPACK.DISPLAYEMPLOYEES()
</sql-query>

I struggled with same issue few months ago. I was using PACKAGES and I came up with this solution.

If you want to find out more you can read a good article which helped me a lot.

UPDATE:

You can mix HBM and fluent mappings.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi LeftyX: But I'm not using Fluent NHibernate classes, so is there any other way of doing this, let me know
@Tarak: I've updated my answer. You can mix HBM and fluent mapping. If my answer is good enough for you, you can mark it as "asnwered" and even up-vote ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.